c++ - Does boost::variant support 64bit integers? -
i tried use boost::variant combined 64 bit integer. unfortunately didn't work. there way fix this? or boost version old? i'm using v1.45.
this declaration works:
std::vector< boost::variant<int, float64_t> > vec2;
this declaration doesn't work:
std::vector< boost::variant<long long int, float64_t> > vec2;
edit
it's compiler error:
error c2668: 'boost::detail::variant::make_initializer_node::apply<baseindexpair,iterator>::initializer_node::initialize' : ambiguous call overloaded function 1> 1> [ 1> baseindexpair=boost::mpl::pair<boost::detail::variant::make_initializer_node::apply<boost::mpl::pair<boost::detail::variant::make_initializer_node::apply<boost::mpl::pair<boost::detail::variant::initializer_root,boost::mpl::int_<0>>,boost::mpl::l_iter<boost::mpl::list3<__int64,double,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>>>::initializer_node,boost::mpl::int_<1>>,boost::mpl::l_iter<boost::mpl::list2<double,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>>>::initializer_node,boost::mpl::int_<2>>, 1> iterator=boost::mpl::l_iter<boost::mpl::list1<std::basic_string<char,std::char_traits<char>,std::allocator<char>>>> 1> ] 1> boost-1_45_0\boost\variant\detail\initializer.hpp(89): 'int boost::detail::variant::make_initializer_node::apply<baseindexpair,iterator>::initializer_node::initialize(void *,const __int64 &)' 1> 1> [ 1> baseindexpair=boost::mpl::pair<boost::detail::variant::initializer_root,boost::mpl::int_<0>>, 1> iterator=boost::mpl::l_iter<boost::mpl::list3<__int64,double,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>> 1> ] 1> boost-1_45_0\boost\variant\detail\initializer.hpp(89): or 'int boost::detail::variant::make_initializer_node::apply<baseindexpair,iterator>::initializer_node::initialize(void *,const double &)' 1> 1> [ 1> baseindexpair=boost::mpl::pair<boost::detail::variant::make_initializer_node::apply<boost::mpl::pair<boost::detail::variant::initializer_root,boost::mpl::int_<0>>,boost::mpl::l_iter<boost::mpl::list3<__int64,double,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>>>::initializer_node,boost::mpl::int_<1>>, 1> iterator=boost::mpl::l_iter<boost::mpl::list2<double,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>> 1> ] 1> while trying match argument list '(void *, const int)' 1> boost-1_45_0\boost\variant\variant.hpp(1373) : see reference function template instantiation 'void boost::variant<t0_,t1,t2>::convert_construct<const t>(t &,int,boost::mpl::false_)' being compiled 1> 1> [ 1> t0_=__int64, 1> t1=float64_t, 1> t2=std::string, 1> t=int 1> ] 1> (1900) : see reference function template instantiation 'boost::variant<t0_,t1,t2>::variant<int>(const t &)' being compiled 1> 1> [ 1> t0_=__int64, 1> t1=float64_t, 1> t2=std::string, 1> t=int 1> ]
edit
the error in code not posted. @hvd has found fault anyway. must explicitly name type - if it's int64.
no error:
std::vector <boost::variant <int, float64_t> > vec; vec.push_back ( 22 );
compiler error:
std::vector <boost::variant <__int64, float64_t> > vec; vec.push_back ( 22 );
no error:
std::vector <boost::variant <__int64, float64_t> > vec; vec.push_back ( (__int64) 22 );
to give short answer: boost::variant support 64bit integers.
but if value assigned boost::variant ambiguous can lead compiler errors (e.g. boost::variant support float , integers , try assign integer). in case explicit typ conversion solves problem.
Comments
Post a Comment