move constructible traits etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
move constructible traits etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

27 Temmuz 2017 Perşembe

move constructible traits

Sınıfın Copyable Olması Yeterli
Açıklaması şöyle
A class copyable is still MoveConstructible and MoveAssignable
Bir diğer açıklama şöyle
Moving can be seen as a special case where the original variable need not be preserved. Preserving the original variable (like copying) does not invalidate the move.
Şöyle yaparız.
struct copyable { // and movable
  copyable() = default;
  copyable(copyable const&) { /*...*/ };
  copyable& operator=(copyable const&) { /*...*/ return *this; }
};
std::is_move_constructible metodu
Açıklaması şöyle
A defaulted move constructor that is defined as deleted is ignored by overload resolution.
Elimizde kalıtım yapan iki sınıf olsun. Foo halen move_constructable olarak true döner.
template <typename Base> struct Foo : public Base {
  using Base::Base;
};

struct Bar {
  Bar(const Bar&) { }
  Bar(Bar&&) = delete;
};

std::cout << std::is_move_constructible<Bar>::value << std::endl; // NO
std::cout << std::is_move_constructible<Foo<Bar>>::value << std::endl; // YES.