I have the following error message:
/usr/include/boost/variant/detail/visitation_impl.hpp:207: typename Visitor::result_type boost::detail::variant::visitation_impl(int, int, Visitor &, VPCV, mpl::true_, NBF, W *, S *) [W = mpl_::int_<20>, S = boost::detail::variant::visitation_impl_step<boost::mpl::l_iter<boost::mpl::l_end>, boost::mpl::l_iter<boost::mpl::l_end> >, Visitor = boost::detail::variant::copy_into, VPCV = const void *, NBF = boost::variant<TypeInfo, int, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>::has_fallback_type_]: Assertion `false' failed.
This happens when I am passing std::vector<A>
as a parameter by value to some function and A
is defined as using A = boost::variant<B, int>;
.
To be simple, B
is defined like this:
class B
{
Data data;
std::vector< boost::variant<std::shared_ptr<C>, B> > vec;
};
B
is TypeInfo
in error message.
void func(std::vector<B> vec); //signature
auto result = func(that_vector_with_variants); //that line causes an error
I have found similar bug here https://svn.boost.org/trac/boost/ticket/5146
My question is: Is it a bug in boost? How can I make my code work?
Update:
I think that I have to add that if I change std::vector<boost::variant<std::shared_ptr<C>, B> > vec;
to std::vector<boost::variant<C*, B> > vec;
then everything works.