0

Say that I have this class for example:

#include <cstdint>

class Color {
private:
    uint8_t red_;
    uint8_t green_;
    uint8_t blue_;
public:
    Color();
    Color(uint8_t red, uint8_t green, uint8_t blue);
    Color(const Color& other);
};

I am wondering if there is any reason to define a move constructor for this?
I understand the reason to define a move constructor for a class with pointer or STL container data member. But in this case, where all data members are primitive types, is there any situation which I will need a move constructor?

A. Sarid
  • 3,916
  • 2
  • 31
  • 56
  • 1
    There is no reason to define a copy constructor, too. And do you really need a default constructor? –  Feb 04 '18 at 10:10
  • @manni66 because the default one is auto generated by the compiler and it will do what I expect it to do in this case? Same thing for the move constructor? Thanks! – A. Sarid Feb 04 '18 at 10:12
  • The copy constructor is generated by the compiler. The default is not generated, but why do you think you need one? –  Feb 04 '18 at 10:16
  • @manni66 Yea I guess you are right. In this case there in no need to have a default constructor. Thank you – A. Sarid Feb 04 '18 at 10:17

0 Answers0