2014-09-02 16:11 GMT+02:00 Dean Michael Berris
On Wed Sep 03 2014 at 12:00:56 AM Andrzej Krzemienski
wrote: And the above incorrect behaviour is the consequence of a more simple bug in VC++. It allows two user defined conversions in copy initialization:
struct A { A(int &&) {}
};
struct B { operator int() { return 0; } };
int main() { A t = B(); }
This works in VC++, although the code is incorrect.
So it does sound like this is one of those r-value reference implementation bugs in MSVC that I've heard before but couldn't cite. Could it just be that Boost.Optional shouldn't turn on rvalue reference support with MSVC 2010? Will defining just the copy constructor "fix" it? More importantly is there something users of Boost 1.56.0 can do to side-step this particular issue in Boost.Optional?
No, it has nothing to do with rvalue refs -- only with illegal double conversion. struct A { A(int) {} }; struct B { operator int() { return 0; } }; int main() { A t = B(); } This is also an illegal C++ but VC++ allows it. See my other reply for a workaround.