Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`X::X(const X&&)` Const Move Constructor? [duplicate]

Tags:

c++

c++11

Possible Duplicate:
Move constructor signature

struct X
{
    X(X&);         // (1)
    X(X&&);        // (2)
    X(const X&);   // (3)
    X(const X&&);  // (4)
};

Are there any situations where (4) will be picked in overload resolution?

like image 473
Andrew Tomazos Avatar asked Sep 01 '26 06:09

Andrew Tomazos


1 Answers

Yes. One situation is when you have a function with a const return value:

const X f();

X x(f());
like image 72
R. Martinho Fernandes Avatar answered Sep 02 '26 21:09

R. Martinho Fernandes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!