Boost logo

Boost Users :

From: Alex Drummond (a.drummond_at_[hidden])
Date: 2004-11-16 05:11:38


Hi,

I'm using boost 1.31.0 and I'm having some trouble using type sequences with
boost::variant. There seems to be an arbitrary limit on their length. For
example, the following code compiles:

[----------------------------------------
#include <boost/variant.hpp>
#include <boost/mpl/vector.hpp>

typedef boost::mpl::vector< boost::recursive_wrapper<struct A> > T0;
typedef boost::mpl::push_front<T0, boost::recursive_wrapper<struct B> >::type
T1;
typedef boost::mpl::push_front<T1, boost::recursive_wrapper<struct C> >::type
T2;
typedef boost::mpl::push_front<T2, boost::recursive_wrapper<struct D> >::type
T3;
typedef boost::mpl::push_front<T3, boost::recursive_wrapper<struct E> >::type
T4;
typedef boost::mpl::push_front<T4, boost::recursive_wrapper<struct F> >::type
T5;
typedef boost::mpl::push_front<T5, boost::recursive_wrapper<struct G> >::type
T6;
typedef boost::mpl::push_front<T6, boost::recursive_wrapper<struct H> >::type
T7;
typedef boost::mpl::push_front<T7, boost::recursive_wrapper<struct I> >::type
T8;

typedef boost::make_variant_over<T8>::type Var;

struct A { Var v; };
struct B { Var v; };
struct C { Var v; };
struct D { Var v; };
struct E { Var v; };
struct F { Var v; };
struct G { Var v; };
struct H { Var v; };
struct I { Var v; };

int main() { return 0; }
----------------------------------------]

But with the addition of one more type to the sequence:

[----------------------------------------
typedef boost::mpl::push_front<T8, boost::recursive_wrapper<struct J> >::type
T9;
......
struct J { Var v; }
----------------------------------------]

And an appropriate redefinition of Var:

typedef boost::make_variant_over<T9>::type Var;

gcc 3.3.3 gives various obscure template error messages:

/usr/include/boost/mpl/apply_if.hpp: In instantiation of
`boost::mpl::push_front<boost::mpl::vector10<boost::recursive_wrapper<J>,
boost::recursive_wrapper<I>, boost::recursive_wrapper<H>,
boost::recursive_wrapper<G>, boost::recursive_wrapper<F>,
boost::recursive_wrapper<E>, boost::recursive_wrapper<D>,
boost::recursive_wrapper<C>, boost::recursive_wrapper<B>,
boost::recursive_wrapper<A> >, boost::detail::variant::backup_holder<void*>
>':
/usr/include/boost/mpl/apply_if.hpp:39: instantiated from
`boost::mpl::apply_if<boost::variant<boost::detail::variant::over_sequence<T9>,
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_, boost::mpl::identity<T9>,
boost::mpl::push_front<boost::mpl::vector10<boost::recursive_wrapper<J>,
boost::recursive_wrapper<I>, boost::recursive_wrapper<H>,
boost::recursive_wrapper<G>, boost::recursive_wrapper<F>,
boost::recursive_wrapper<E>, boost::recursive_wrapper<D>,
boost::recursive_wrapper<C>, boost::recursive_wrapper<B>,
boost::recursive_wrapper<A> >, boost::detail::variant::backup_holder<void*> >
>'
/usr/include/boost/variant/variant.hpp:226: instantiated from
`boost::detail::variant::make_storage<boost::mpl::vector10<boost::recursive_wrapper<J>,
boost::recursive_wrapper<I>, boost::recursive_wrapper<H>,
boost::recursive_wrapper<G>, boost::recursive_wrapper<F>,
boost::recursive_wrapper<E>, boost::recursive_wrapper<D>,
boost::recursive_wrapper<C>, boost::recursive_wrapper<B>,
boost::recursive_wrapper<A> >,
boost::variant<boost::detail::variant::over_sequence<T9>,
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_>'
/usr/include/boost/variant/variant.hpp:1079: instantiated from
`boost::variant<boost::detail::variant::over_sequence<T9>,
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_>'
test.cc:19: instantiated from here
/usr/include/boost/mpl/apply_if.hpp:39: error: base class `
   boost::mpl::push_front_traits<boost::mpl::aux::vector_tag<10>
>::algorithm<boost::mpl::vector10<boost::recursive_wrapper<J>,
   boost::recursive_wrapper<I>, boost::recursive_wrapper<H>,
   boost::recursive_wrapper<G>, boost::recursive_wrapper<F>,
   boost::recursive_wrapper<E>, boost::recursive_wrapper<D>,
   boost::recursive_wrapper<C>, boost::recursive_wrapper<B>,
   boost::recursive_wrapper<A> >, boost::detail::variant::backup_holder<void*>
>' has incomplete type
/usr/include/boost/mpl/apply_if.hpp: In instantiation of
`boost::mpl::apply_if<boost::variant<boost::detail::variant::over_sequence<T9>,
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_, boost::mpl::identity<T9>,
boost::mpl::push_front<boost::mpl::vector10<boost::recursive_wrapper<J>,
boost::recursive_wrapper<I>, boost::recursive_wrapper<H>,
boost::recursive_wrapper<G>, boost::recursive_wrapper<F>,
boost::recursive_wrapper<E>, boost::recursive_wrapper<D>,
boost::recursive_wrapper<C>, boost::recursive_wrapper<B>,
boost::recursive_wrapper<A> >, boost::detail::variant::backup_holder<void*> >
>':
/usr/include/boost/variant/variant.hpp:226: instantiated from
`boost::detail::variant::make_storage<boost::mpl::vector10<boost::recursive_wrapper<J>,
boost::recursive_wrapper<I>, boost::recursive_wrapper<H>,
boost::recursive_wrapper<G>, boost::recursive_wrapper<F>,
boost::recursive_wrapper<E>, boost::recursive_wrapper<D>,
boost::recursive_wrapper<C>, boost::recursive_wrapper<B>,
boost::recursive_wrapper<A> >,
boost::variant<boost::detail::variant::over_sequence<T9>,
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_>'
/usr/include/boost/variant/variant.hpp:1079: instantiated from
`boost::variant<boost::detail::variant::over_sequence<T9>,
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_>'
test.cc:19: instantiated from here
/usr/include/boost/mpl/apply_if.hpp:39: error: no type named `type' in `struct
   boost::mpl::push_front<boost::mpl::vector10<boost::recursive_wrapper<J>,
   boost::recursive_wrapper<I>, boost::recursive_wrapper<H>,
   boost::recursive_wrapper<G>, boost::recursive_wrapper<F>,
   boost::recursive_wrapper<E>, boost::recursive_wrapper<D>,
   boost::recursive_wrapper<C>, boost::recursive_wrapper<B>,
   boost::recursive_wrapper<A> >, boost::detail::variant::backup_holder<void*>
>'
/usr/include/boost/variant/variant.hpp: In instantiation of
`boost::detail::variant::make_storage<boost::mpl::vector10<boost::recursive_wrapper<J>,
boost::recursive_wrapper<I>, boost::recursive_wrapper<H>,
boost::recursive_wrapper<G>, boost::recursive_wrapper<F>,
boost::recursive_wrapper<E>, boost::recursive_wrapper<D>,
boost::recursive_wrapper<C>, boost::recursive_wrapper<B>,
boost::recursive_wrapper<A> >,
boost::variant<boost::detail::variant::over_sequence<T9>,
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_>':
/usr/include/boost/variant/variant.hpp:1079: instantiated from
`boost::variant<boost::detail::variant::over_sequence<T9>,
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_>'
test.cc:19: instantiated from here
/usr/include/boost/variant/variant.hpp:226: error: no type named `type' in `
   struct
   boost::mpl::apply_if<boost::variant<boost::detail::variant::over_sequence<T9>,
   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_,
   boost::mpl::identity<T9>,
   boost::mpl::push_front<boost::mpl::vector10<boost::recursive_wrapper<J>,
   boost::recursive_wrapper<I>, boost::recursive_wrapper<H>,
   boost::recursive_wrapper<G>, boost::recursive_wrapper<F>,
   boost::recursive_wrapper<E>, boost::recursive_wrapper<D>,
   boost::recursive_wrapper<C>, boost::recursive_wrapper<B>,
   boost::recursive_wrapper<A> >, boost::detail::variant::backup_holder<void*>
> >'
/usr/include/boost/variant/variant.hpp:230: error: no type named `type' in `
   struct
   boost::mpl::apply_if<boost::variant<boost::detail::variant::over_sequence<T9>,
   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_,
   boost::mpl::identity<T9>,
   boost::mpl::push_front<boost::mpl::vector10<boost::recursive_wrapper<J>,
   boost::recursive_wrapper<I>, boost::recursive_wrapper<H>,
   boost::recursive_wrapper<G>, boost::recursive_wrapper<F>,
   boost::recursive_wrapper<E>, boost::recursive_wrapper<D>,
   boost::recursive_wrapper<C>, boost::recursive_wrapper<B>,
   boost::recursive_wrapper<A> >, boost::detail::variant::backup_holder<void*>
> >'
/usr/include/boost/variant/variant.hpp:236: error: no type named `type' in `
   struct
   boost::mpl::apply_if<boost::variant<boost::detail::variant::over_sequence<T9>,
   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_,
   boost::mpl::identity<T9>,
   boost::mpl::push_front<boost::mpl::vector10<boost::recursive_wrapper<J>,
   boost::recursive_wrapper<I>, boost::recursive_wrapper<H>,
   boost::recursive_wrapper<G>, boost::recursive_wrapper<F>,
   boost::recursive_wrapper<E>, boost::recursive_wrapper<D>,
   boost::recursive_wrapper<C>, boost::recursive_wrapper<B>,
   boost::recursive_wrapper<A> >, boost::detail::variant::backup_holder<void*>
> >'
/usr/include/boost/variant/variant.hpp:252: error: no type named `type' in `
   struct
   boost::mpl::apply_if<boost::variant<boost::detail::variant::over_sequence<T9>,
   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_,
   boost::mpl::identity<T9>,
   boost::mpl::push_front<boost::mpl::vector10<boost::recursive_wrapper<J>,
   boost::recursive_wrapper<I>, boost::recursive_wrapper<H>,
   boost::recursive_wrapper<G>, boost::recursive_wrapper<F>,
   boost::recursive_wrapper<E>, boost::recursive_wrapper<D>,
   boost::recursive_wrapper<C>, boost::recursive_wrapper<B>,
   boost::recursive_wrapper<A> >, boost::detail::variant::backup_holder<void*>
> >'
/usr/include/boost/variant/variant.hpp: In instantiation of
`boost::variant<boost::detail::variant::over_sequence<T9>,
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_>':
test.cc:19: instantiated from here
/usr/include/boost/variant/variant.hpp:1079: error: no type named `type' in `
   struct
   boost::detail::variant::make_storage<boost::mpl::vector10<boost::recursive_wrapper<J>,
   boost::recursive_wrapper<I>, boost::recursive_wrapper<H>,
   boost::recursive_wrapper<G>, boost::recursive_wrapper<F>,
   boost::recursive_wrapper<E>, boost::recursive_wrapper<D>,
   boost::recursive_wrapper<C>, boost::recursive_wrapper<B>,
   boost::recursive_wrapper<A> >,
   boost::variant<boost::detail::variant::over_sequence<T9>,
   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_>'
/usr/include/boost/variant/variant.hpp:1118: error: no type named `type' in `
   struct
   boost::detail::variant::make_storage<boost::mpl::vector10<boost::recursive_wrapper<J>,
   boost::recursive_wrapper<I>, boost::recursive_wrapper<H>,
   boost::recursive_wrapper<G>, boost::recursive_wrapper<F>,
   boost::recursive_wrapper<E>, boost::recursive_wrapper<D>,
   boost::recursive_wrapper<C>, boost::recursive_wrapper<B>,
   boost::recursive_wrapper<A> >,
   boost::variant<boost::detail::variant::over_sequence<T9>,
   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_>'

I'd be grateful for any help...
Thanks
Alex

-- 
"What possible harm could one insane mutant tentacle do?"

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