1

I know that a copy constructor is always created by default even if I don't explicitly create one. Is the same true for a move constructor? Let's assume a have a very simple class:

class SimpleClass
{

public:
    SimpleClass(int value) :
            member(value)
    {}

    int member;

};

Do I explicitly need to write SimpleClass(SimpleClass &&other) default to create the default move constructor or not?

Thomas Sparber
  • 2,827
  • 2
  • 18
  • 34
  • 2
    Look at [conditions-for-automatic-generation-of-default-ctor-copy-ctor-and-default-assignment](http://stackoverflow.com/questions/4943958/conditions-for-automatic-generation-of-default-ctor-copy-ctor-and-default-assi) – Jarod42 Sep 29 '15 at 08:19
  • 1
    Watch out for Visual Studio versions prior to 2015 they did not create move constructor by default. – Chris Drew Sep 29 '15 at 08:25

1 Answers1

1

Like the copy constructor the move construction is available by default. Check the reference docu here

Jarod42
  • 203,559
  • 14
  • 181
  • 302
Jerome Anthony
  • 7,823
  • 2
  • 40
  • 31
  • 3
    Except, that if you declare a copy constructor, destructor or assignment operator, move operations won't be generated. – Melkon Sep 29 '15 at 08:22