LINUX.ORG.RU

История изменений

Исправление art_corp, (текущая версия) :

Как бы намеки хорошие, но и с public конструктором ошибка повторяется.
Исходный код был:

class PointF
{
    void InitQPointF() const;
    void CopyMembersFrom(const Gdiplus::PointF& point);    
public:
    PointF(const Gdiplus::PointF& point) noexcept;
    PointF& operator=(const Gdiplus::PointF& point);
в соотв. с рекомендациями: Ensuring move is used, rather than copy

If you want to be sure that moves are being done, you can disable
copy semantics in your classes (and create wrappers for STL
classes with copying disabled), so that you when you are
moving objects of the class around, you know for sure they're
either being cheaply moved, or that the compiler will
complain if any bit of code is wanting to copy

я запретил копирование, добавил move конструктор.
Но это не верный путь.
К тому же в STL же есть шаблон для общей ситуации:
 template<bool _TrivialValueTypes>
    struct __uninitialized_copy
    {
      template<typename _InputIterator, typename _ForwardIterator>
        static _ForwardIterator
        __uninit_copy(_InputIterator __first, _InputIterator __last,
		      _ForwardIterator __result)
        {
	  _ForwardIterator __cur = __result;
	  __try
	    {
	      for (; __first != __last; ++__first, ++__cur)
		std::_Construct(std::__addressof(*__cur), *__first);
	      return __cur;
	    }
	  __catch(...)
	    {
	      std::_Destroy(__result, __cur);
	      __throw_exception_again;
	    }
	}
    };

  template<>
    struct __uninitialized_copy<true>
    {
      template<typename _InputIterator, typename _ForwardIterator>
        static _ForwardIterator
        __uninit_copy(_InputIterator __first, _InputIterator __last,
		      _ForwardIterator __result)
        { return std::copy(__first, __last, __result); }
    };

Исходная версия art_corp, :

Как бы намеки хорошие, но и с public конструктором ошибка повторяется.
Исходный код был:

class PointF
{
    void InitQPointF() const;
    void CopyMembersFrom(const Gdiplus::PointF& point);    
public:
    PointF(const Gdiplus::PointF& point) noexcept;
    PointF& operator=(const Gdiplus::PointF& point);
в соотв. с рекомендациями: Ensuring move is used, rather than copy

If you want to be sure that moves are being done, you can disable
copy semantics in your classes (and create wrappers for STL
classes with copying disabled), so that you when you are
moving objects of the class around, you know for sure they're
either being cheaply moved, or that the compiler will
complain if any bit of code is wanting to copy