Boost logo

Boost Users :

Subject: [Boost-users] [boost::variant] problem with swap
From: Ondrej Kuncar (kxenator_at_[hidden])
Date: 2009-12-20 10:28:20


Hello!

I have problems to compile this code with Visual Studio 9.0 SP1 and
Boost 1.41:

-------------------------------------------------------------------

#include <boost/variant.hpp>
#include <deque>

typedef boost::variant<std::deque<int>::iterator> SemanticValue;

int main() {
        SemanticValue v1;
        SemanticValue v2;
        v1.swap(v2);
}

-------------------------------------------------------------------

I got this error:

c:\program files\boost\boost_1_41_0\boost\variant\detail\move.hpp(155) :
error C2668: 'std::swap' : ambiguous call to overloaded function
        c:\program
files\boost\boost_1_41_0\boost\variant\detail\move.hpp(141): could be
'void boost::detail::variant::detail::move_swap::swap<T>(T &,T &)'
        with
        [
            T=T0
        ]
        c:\program files\microsoft visual studio
9.0\vc\include\utility(16): or 'void std::swap<T>(_Ty &,_Ty &)'
[found using argument-dependent lookup]
        with
        [
            T=T0,
            _Ty=T0
        ]
        while trying to match the argument list '(T0, T0)'
        c:\program
files\boost\boost_1_41_0\boost\variant\variant.hpp(698) : see reference
to function template instantiation 'void
boost::detail::variant::move_swap<T>(T &,T &)' being compiled
        with
        [
            T=T0
        ]
        c:\program
files\boost\boost_1_41_0\boost\variant\variant.hpp(825) : see reference
to function template instantiation 'void
boost::detail::variant::swap_with<Variant>::operator ()<T>(T &) const'
being compiled
        with
        [

Variant=boost::variant<std::_Deque_iterator<int,std::allocator<int>,true>>,
            T=T0
        ]
        c:\program
files\boost\boost_1_41_0\boost\variant\detail\visitation_impl.hpp(141) :
see reference to function template instantiation 'void
boost::detail::variant::invoke_visitor<Visitor>::internal_visit<T>(T
&,int)' being compiled
        with
        [

Visitor=boost::detail::variant::swap_with<boost::variant<std::_Deque_iterator<int,std::allocator<int>,true>>>,
            T=T0
        ]
        c:\program
files\boost\boost_1_41_0\boost\variant\detail\visitation_impl.hpp(169) :
see reference to function template instantiation 'void
boost::detail::variant::visitation_impl_invoke_impl<Visitor,VoidPtrCV,T>(int,Visitor
&,VoidPtrCV,T *,boost::mpl::false_)' being compiled
        with
        [

Visitor=boost::detail::variant::invoke_visitor<boost::detail::variant::swap_with<boost::variant<std::_Deque_iterator<int,std::allocator<int>,true>>>>,
            VoidPtrCV=void *,
            T=T0
        ]
        c:\program
files\boost\boost_1_41_0\boost\variant\detail\visitation_impl.hpp(252) :
see reference to function template instantiation 'void
boost::detail::variant::visitation_impl_invoke<Visitor,VoidPtrCV,T0,NoBackupFlag>(int,Visitor
&,VoidPtrCV,T *,NoBackupFlag,int)' being compiled
        with
        [

Visitor=boost::detail::variant::invoke_visitor<boost::detail::variant::swap_with<boost::variant<std::_Deque_iterator<int,std::allocator<int>,true>>>>,
            VoidPtrCV=void *,

NoBackupFlag=boost::variant<std::_Deque_iterator<int,std::allocator<int>,true>>::has_fallback_type_,
            T=T0
        ]
        c:\program
files\boost\boost_1_41_0\boost\variant\variant.hpp(1769) : see reference
to function template instantiation 'void
boost::detail::variant::visitation_impl<first_which,first_step,Visitor,VoidPtrCV,boost::variant<T0_>::has_fallback_type_>(const
int,const int,Visitor &,VoidPtrCV,boost::mpl::false_,NoBackupFlag,Which
*,step0 *)' being compiled
        with
        [

Visitor=boost::detail::variant::invoke_visitor<boost::detail::variant::swap_with<boost::variant<std::_Deque_iterator<int,std::allocator<int>,true>>>>,
            VoidPtrCV=void *,
            T0_=std::_Deque_iterator<int,std::allocator<int>,true>,

NoBackupFlag=boost::variant<std::_Deque_iterator<int,std::allocator<int>,true>>::has_fallback_type_,
            Which=first_which,
            step0=first_step
        ]
        c:\program
files\boost\boost_1_41_0\boost\variant\variant.hpp(1780) : see reference
to function template instantiation 'void
boost::variant<T0_>::internal_apply_visitor_impl<Visitor,void*>(int,int,Visitor
&,VoidPtrCV)' being compiled
        with
        [
            T0_=std::_Deque_iterator<int,std::allocator<int>,true>,

Visitor=boost::detail::variant::invoke_visitor<boost::detail::variant::swap_with<boost::variant<std::_Deque_iterator<int,std::allocator<int>,true>>>>,
            VoidPtrCV=void *
        ]
        c:\program
files\boost\boost_1_41_0\boost\variant\variant.hpp(1803) : see reference
to function template instantiation 'void
boost::variant<T0_>::internal_apply_visitor<boost::detail::variant::invoke_visitor<Visitor>>(boost::detail::variant::invoke_visitor<Visitor>
&)' being compiled
        with
        [
            T0_=std::_Deque_iterator<int,std::allocator<int>,true>,

Visitor=boost::detail::variant::swap_with<boost::variant<std::_Deque_iterator<int,std::allocator<int>,true>>>
        ]
        c:\program
files\boost\boost_1_41_0\boost\variant\variant.hpp(1637) : see reference
to function template instantiation 'void
boost::variant<T0_>::apply_visitor<boost::detail::variant::swap_with<Variant>>(Visitor
&)' being compiled
        with
        [
            T0_=std::_Deque_iterator<int,std::allocator<int>,true>,

Variant=boost::variant<std::_Deque_iterator<int,std::allocator<int>,true>>,

Visitor=boost::detail::variant::swap_with<boost::variant<std::_Deque_iterator<int,std::allocator<int>,true>>>
        ]
        c:\program
files\boost\boost_1_41_0\boost\variant\variant.hpp(1631) : while
compiling class template member function 'void
boost::variant<T0_>::swap(boost::variant<T0_> &)'
        with
        [
            T0_=std::_Deque_iterator<int,std::allocator<int>,true>
        ]
        d:\dokumenty\visual studio
2008\projects\pokus4\pokus4\pokus4.cpp(20) : see reference to class
template instantiation 'boost::variant<T0_>' being compiled
        with
        [
            T0_=std::_Deque_iterator<int,std::allocator<int>,true>
        ]

Do you have any ideas?

Thanks.

OK


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net