On 06/03/10 04:22, Mathieu Malaterre wrote:
On Tue, Jun 1, 2010 at 4:42 PM, Larry Evans wrote:
[snip]
Look out for the boost:;variant trap revealed by the post:
http://article.gmane.org/gmane.comp.lib.boost.user/58791
The problem occurs when one component can be constructed from another
component. as suggested by this quote from the above post:
When bool is added to variant, the statement
variant = "hello world" ;
calls bool constructor.
I think something similar may happen here, but maybe the problem
can be solved by some order of the bound components. Maybe putting
more "stringent" components either first or last. That way, maybe
the correct one would be selected when the assignment is made.
Thanks for the warning. My base type are fundamental type, so I should
not suffer from this implicit cast.
The 1st attachment, when compiled with gcc4.4 I,
gives errors in 2nd attachment.
When the '#if 1' is replaced with '#if 0' it compiles OK, indicating
that you must explicitly cast the argument type to avoid the
ambiguity error in this particular case.
HTH.
-Larry
In file included from /home/evansl/prog_dev/boost-svn/ro/trunk/boost/variant.hpp:17,
from variant_implicit_conversion.cpp:5:
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/variant/variant.hpp: In member function 'void boost::variant::convert_construct(T&, int, mpl_::false_) [with T = const double, T0_ = int, T1 = float, T2 = boost::detail::variant::void_, T3 = boost::detail::variant::void_, T4 = boost::detail::variant::void_, T5 = boost::detail::variant::void_, T6 = boost::detail::variant::void_, T7 = boost::detail::variant::void_, T8 = boost::detail::variant::void_, T9 = boost::detail::variant::void_, T10 = boost::detail::variant::void_, T11 = boost::detail::variant::void_, T12 = boost::detail::variant::void_, T13 = boost::detail::variant::void_, T14 = boost::detail::variant::void_, T15 = boost::detail::variant::void_, T16 = boost::detail::variant::void_, T17 = boost::detail::variant::void_, T18 = boost::detail::variant::void_, T19 = boost::detail::variant::void_]':
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/variant/variant.hpp:1372: instantiated from 'boost::variant::variant(const T&) [with T = double, T0_ = int, T1 = float, T2 = boost::detail::variant::void_, T3 = boost::detail::variant::void_, T4 = boost::detail::variant::void_, T5 = boost::detail::variant::void_, T6 = boost::detail::variant::void_, T7 = boost::detail::variant::void_, T8 = boost::detail::variant::void_, T9 = boost::detail::variant::void_, T10 = boost::detail::variant::void_, T11 = boost::detail::variant::void_, T12 = boost::detail::variant::void_, T13 = boost::detail::variant::void_, T14 = boost::detail::variant::void_, T15 = boost::detail::variant::void_, T16 = boost::detail::variant::void_, T17 = boost::detail::variant::void_, T18 = boost::detail::variant::void_, T19 = boost::detail::variant::void_]'
variant_implicit_conversion.cpp:20: instantiated from here
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/variant/variant.hpp:1299: error: call of overloaded 'initialize(void*, const double&)' is ambiguous
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/variant/detail/initializer.hpp:89: note: candidates are: static int boost::detail::variant::make_initializer_node::apply::initializer_node::initialize(void*, typename boost::call_traits::type>::param_type) [with BaseIndexPair = boost::mpl::pair >, boost::mpl::l_iter > >::initializer_node, mpl_::int_<1> >, Iterator = boost::mpl::l_iter]
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/variant/detail/initializer.hpp:89: note: static int boost::detail::variant::make_initializer_node::apply::initializer_node::initialize(void*, typename boost::call_traits::type>::param_type) [with BaseIndexPair = boost::mpl::pair >, Iterator = boost::mpl::l_iter >]
make: *** [/home/evansl/prog_dev/boost-svn/ro/trunk/sandbox-local/build/gcc4_4n/boost-svn/ro/sandbox/variadic_templates/libs/composite_storage/sandbox/pack/variant_implicit_conversion.o] Error 1