[move] abiguious ctor (msvc-10.0)

I get error C2668 with msvc-10.0 - (gcc.4.x works). Any ideas? 1>test.cpp(44): error C2668: 'X::X': Mehrdeutiger Aufruf einer überladenen Funktion 1> test.cpp(19): kann 'X::X<boost::_bi::bind_t<R,F,L>>(Fn &&,size_t)' sein 1> with 1> [ 1> R=void, 1> F=void (__cdecl *)(int), 1> L=boost::_bi::list1<boost::_bi::value<int>>, 1> Fn=boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::value<int>>> 1> ] 1> test.cpp(16): oder "X::X<boost::_bi::bind_t<R,F,L>>(Fn,size_t)" 1> with 1> [ 1> R=void, 1> F=void (__cdecl *)(int), 1> L=boost::_bi::list1<boost::_bi::value<int>>, 1> Fn=boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::value<int>>> 1> ] 1> bei Anpassung der Argumentliste '(boost::_bi::bind_t<R,F,L>, int)' 1> with 1> [ 1> R=void, 1> F=void (__cdecl *)(int), 1> L=boost::_bi::list1<boost::_bi::value<int>> 1> ] test app: #include <cstdlib> #include <iostream> #include <boost/bind.hpp> #include <boost/move/move.hpp> class X { private: BOOST_COPYABLE_AND_MOVABLE( X); public: X() {} template< typename Fn > X( Fn fn, std::size_t i) {} template< typename Fn > X( BOOST_RV_REF( Fn) fn, std::size_t i) {} X( X const& other) {} X & operator=( BOOST_COPY_ASSIGN_REF( X) other) { X tmp( other); return * this; } X( BOOST_RV_REF( X) other) {} X & operator=( BOOST_RV_REF( X) other) { X tmp( boost::move( other) ); return * this; } }; void f( int) {} int main() { try { X x( boost::bind( f, 1), 1); return EXIT_SUCCESS; } catch ( std::exception const& e) { std::cerr << "exception: " << e.what() << std::endl; } catch (...) { std::cerr << "unhandled exception" << std::endl; } return EXIT_FAILURE; } -- Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief! Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail

At Tue, 11 Jan 2011 14:10:54 +0100, Oliver Kowalke wrote:
I get error C2668 with msvc-10.0 - (gcc.4.x works). Any ideas?
1> test.cpp(19): kann 'X::X<boost::_bi::bind_t<R,F,L>>(Fn &&,size_t)' sein 1> test.cpp(16): oder "X::X<boost::_bi::bind_t<R,F,L>>(Fn,size_t)"
If the library is indeed generating both of those overloads, I'm not surprised you're seeing the problem. The 2nd one should take Fn by reference. -- Dave Abrahams BoostPro Computing http://www.boostpro.com

the 2nd one isn't generated by the move lib. why is the 2nd version which takes Fn as value equivalent to the 1st one? I'm confused because gcc accepts the code and msvc rejects it. Am 11.01.2011 14:57, schrieb Dave Abrahams:
At Tue, 11 Jan 2011 14:10:54 +0100, Oliver Kowalke wrote:
I get error C2668 with msvc-10.0 - (gcc.4.x works). Any ideas?
1> test.cpp(19): kann 'X::X<boost::_bi::bind_t<R,F,L>>(Fn&&,size_t)' sein 1> test.cpp(16): oder "X::X<boost::_bi::bind_t<R,F,L>>(Fn,size_t)"
If the library is indeed generating both of those overloads, I'm not surprised you're seeing the problem. The 2nd one should take Fn by reference.

At Tue, 11 Jan 2011 19:32:55 +0100, Oliver Kowalke wrote:
the 2nd one isn't generated by the move lib. why is the 2nd version which takes Fn as value equivalent to the 1st one?
It's an equally-good match because... that's what the language rules say.
I'm confused because gcc accepts the code and msvc rejects it.
The language rules weren't perfectly stable when these implementations came out (it's a pre-release feature after all) and compilers have bugs, so there's no cause for confusion :-) -- Dave Abrahams BoostPro Computing http://www.boostpro.com
participants (2)
-
Dave Abrahams
-
Oliver Kowalke