struct X {
X() {}
X(X&&) { }
};
X global_m;
struct Converts {
operator X&& () const { return std::move(global_m); }
};
I believe the following should work:
X x { Converts{} };
There is only one single-argument constructor for X. It takes an X&&
. The Converts object is temporary, and it converts to X&&
. So why do I get this error message from clang-3.3:
// error: "candidate constructor not viable: no known conversion from 'Converts' to 'X &&' for 1st argument"
I'm able to explicitly call the operator as:
X x { Converts{}.operator struct X&& () }; // this works.
Unfortunately for me, it works on ideone, which is based on g++ as far as I know. Is there any online clang compiler that's up and running at the moment?