0
class X {
public:
    X() {}
    X(const X&) {
        std::cou << "copy constructor";
    }
    X(X&&) {
        std::cout << "move constructor";
    }
};

X func() { return X(); }

int main() {
    X x(func()); // nothing is printed
}

I think that the move constructor must be called, but neither copy constructor nor move constructor gets called. Is this because of copy ellision?

beginpluses
  • 497
  • 2
  • 9

0 Answers0