[Boost-bugs] [Boost C++ Libraries] #2839: move-emulated swap causes overloaded ambiguous fun call

Subject: [Boost-bugs] [Boost C++ Libraries] #2839: move-emulated swap causes overloaded ambiguous fun call
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-03-09 13:37:52


#2839: move-emulated swap causes overloaded ambiguous fun call
--------------------------+-------------------------------------------------
 Reporter: st_at_[hidden] | Owner: ebf
     Type: Bugs | Status: new
Milestone: Boost 1.39.0 | Component: variant
  Version: Boost 1.38.0 | Severity: Problem
 Keywords: |
--------------------------+-------------------------------------------------
 The attached test file is a minimal example of something I have a real-
 world use for (with T instead of int), and it doesn't compile in MS Visual
 Studio 2005 or 2008. The error message is too long as it's templated code,
 but the head follows:
 1>c:\Users\dh\products\avir\include\boost/variant/detail/move.hpp(155) :
 error C2668: 'boost::detail::variant::detail::move_swap::swap' : ambiguous
 call to overloaded function
 1>
 c:\Users\dh\products\avir\include\boost/variant/detail/move.hpp(141):
 could be 'void boost::detail::variant::detail::move_swap::swap<T>(T &,T
 &)'
 1> with
 1> [
 1> T=T2
 1> ]
 1> C:\Program Files (x86)\Microsoft Visual Studio
 9.0\VC\include\utility(16): or 'void std::swap<T>(_Ty &,_Ty &)'
 [found using argument-dependent lookup]
 1> with
 1> [
 1> T=T2,
 1> _Ty=T2
 1> ]
 1> while trying to match the argument list '(T2 , T2 )'
 1> c:\Users\dh\products\avir\include\boost/variant/variant.hpp(684)
 : see reference to function template instantiation 'void
 boost::detail::variant::move_swap<T>(T &,T &)' being compiled
 1> with
 1> [
 1> T=T2
 1> ]

 The crucial code is in variant/detail/move.hpp, from line 114. As my
 variant includes a std::vector<T>*, it finds std::swap in the unqualified
 call on line 155.

 The code in question is protected by a BOOST_WORKAROUND that disables it
 for gcc. I tested this case on gcc, and it works fine, but fails in the
 same way if I remove the workaround. The comment above it claims that it
 falls back for "non-conforming compilers," but I'm not convinced that the
 expected behaviour is conformant. Basic.lookup.koenig says explicitly that
 "If T is a pointer to U or an array of U, its associated namespaces and
 classes are those associated with U."

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/2839>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:59 UTC