implicit-constructor

Move object without a move constructor

∥☆過路亽.° 提交于 2020-01-03 19:16:30
问题 One more time about this, but the related questions do not answer my question. The standard is pretty clear: 12.8 Copying and moving class objects, §9 If the definition of a class X does not explicitly declare a move constructor, one will be implicitly declared as defaulted if and only if — X does not have a user-declared copy constructor, — X does not have a user-declared copy assignment operator, — X does not have a user-declared move assignment operator, — X does not have a user-declared

Move object without a move constructor

怎甘沉沦 提交于 2020-01-03 19:16:10
问题 One more time about this, but the related questions do not answer my question. The standard is pretty clear: 12.8 Copying and moving class objects, §9 If the definition of a class X does not explicitly declare a move constructor, one will be implicitly declared as defaulted if and only if — X does not have a user-declared copy constructor, — X does not have a user-declared copy assignment operator, — X does not have a user-declared move assignment operator, — X does not have a user-declared

Why is forwarding reference constructor called instead of copy constructor?

余生颓废 提交于 2019-12-23 15:47:57
问题 Given the following code #include <iostream> using namespace std; template <typename Type> struct Something { Something() { cout << "Something()" << endl; } template <typename SomethingType> Something(SomethingType&&) { cout << "Something(SomethingType&&)" << endl; } }; int main() { Something<int> something_else{Something<int>{}}; auto something = Something<int>{}; Something<int>{something}; return 0; } I get the following output Something() Something() Something(SomethingType&&) Why is the