dimanche 4 février 2018

Do I need to define move constructor for class with only non-pointer primitive types members? [duplicate]

This question already has an answer here:

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?

Aucun commentaire:

Enregistrer un commentaire