How to use Boost Spirit with variant with more than 20 types?
===

I'm parsing a quite complex grammar with Boost Spirit and I'm facing a problem with a variant that have more than 20 types (21 here): 

    namespace eddic { namespace ast {
    
    typedef boost::mpl::vector<
                Integer,
                IntegerSuffix,
                Float,
                Litteral,
                VariableValue,
                DereferenceValue,
                Expression,
                Unary,
                Null,
                True,
                False,
                ArrayValue,
                FunctionCall,
                MemberFunctionCall,
                Cast,
                BuiltinOperator,
                Assignment,
                SuffixOperation,
                PrefixOperation,
                Ternary
            > types_initial;
    
    typedef boost::mpl::push_back<types_initial, New>::type types;
    typedef boost::make_variant_over<types>::type Value;
    
    }}

Boost Spirit does not recognize the last type (eddic::ast::New) added with push_back. When I parse something that have this element, it fails with this error: 

> eddic: /usr/include/boost/variant/detail/visitation_impl.hpp:264:
> typename Visitor::result_type
> boost::detail::variant::visitation_impl(int, int, Visitor&, VoidPtrCV,
> mpl_::false_, NoBackupFlag, Which*, step0*) [with Which =
> mpl_::int_<0>; step0 =
> boost::detail::variant::visitation_impl_step<boost::mpl::v_iter<boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTNew>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTTernary>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTPrefixOperation>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTSuffixOperation>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTAssignment>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTBuiltinOperator>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTCast>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTMemberFunctionCall>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTFunctionCall>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTArrayValue>,
> boost::mpl::v_item<eddic::ast::False,
> boost::mpl::v_item<eddic::ast::True,
> boost::mpl::v_item<eddic::ast::Null,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTUnary>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTExpression>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTDereferenceValue>,
> boost::mpl::v_item<eddic::ast::VariableValue,
> boost::mpl::v_item<eddic::ast::Litteral,
> boost::mpl::v_item<eddic::ast::Float,
> boost::mpl::v_item<eddic::ast::IntegerSuffix,
> boost::mpl::v_item<eddic::ast::Integer, boost::mpl::vector0<mpl_::na>,
> 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>,
> 0>, 0>, 0>, 0>, 0l>,
> boost::mpl::v_iter<boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTNew>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTTernary>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTPrefixOperation>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTSuffixOperation>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTAssignment>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTBuiltinOperator>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTCast>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTMemberFunctionCall>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTFunctionCall>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTArrayValue>,
> boost::mpl::v_item<eddic::ast::False,
> boost::mpl::v_item<eddic::ast::True,
> boost::mpl::v_item<eddic::ast::Null,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTUnary>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTExpression>,
> boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTDereferenceValue>,
> boost::mpl::v_item<eddic::ast::VariableValue,
> boost::mpl::v_item<eddic::ast::Litteral,
> boost::mpl::v_item<eddic::ast::Float,
> boost::mpl::v_item<eddic::ast::IntegerSuffix,
> boost::mpl::v_item<eddic::ast::Integer, boost::mpl::vector0<mpl_::na>,
> 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>, 0>,
> 0>, 0>, 0>, 0>, 21l> >; Visitor =
> boost::variant<boost::detail::variant::over_sequence<boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTNew>, boost::mpl::vector<eddic::ast::Integer, eddic::ast::IntegerSuffix,
> eddic::ast::Float, eddic::ast::Litteral, eddic::ast::VariableValue,
> eddic::ast::Deferred<eddic::ast::ASTDereferenceValue>,
> eddic::ast::Deferred<eddic::ast::ASTExpression>,
> eddic::ast::Deferred<eddic::ast::ASTUnary>, eddic::ast::Null,
> eddic::ast::True, eddic::ast::False,
> eddic::ast::Deferred<eddic::ast::ASTArrayValue>,
> eddic::ast::Deferred<eddic::ast::ASTFunctionCall>,
> eddic::ast::Deferred<eddic::ast::ASTMemberFunctionCall>,
> eddic::ast::Deferred<eddic::ast::ASTCast>,
> eddic::ast::Deferred<eddic::ast::ASTBuiltinOperator>,
> eddic::ast::Deferred<eddic::ast::ASTAssignment>,
> eddic::ast::Deferred<eddic::ast::ASTSuffixOperation>,
> eddic::ast::Deferred<eddic::ast::ASTPrefixOperation>,
> eddic::ast::Deferred<eddic::ast::ASTTernary> >, 0> >,
> 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_,
> boost::detail::variant::void_>::assigner; VoidPtrCV = const void*;
> NoBackupFlag =
> boost::variant<boost::detail::variant::over_sequence<boost::mpl::v_item<eddic::ast::Deferred<eddic::ast::ASTNew>, boost::mpl::vector<eddic::ast::Integer, eddic::ast::IntegerSuffix,
> eddic::ast::Float, eddic::ast::Litteral, eddic::ast::VariableValue,
> eddic::ast::Deferred<eddic::ast::ASTDereferenceValue>,
> eddic::ast::Deferred<eddic::ast::ASTExpression>,
> eddic::ast::Deferred<eddic::ast::ASTUnary>, eddic::ast::Null,
> eddic::ast::True, eddic::ast::False,
> eddic::ast::Deferred<eddic::ast::ASTArrayValue>,
> eddic::ast::Deferred<eddic::ast::ASTFunctionCall>,
> eddic::ast::Deferred<eddic::ast::ASTMemberFunctionCall>,
> eddic::ast::Deferred<eddic::ast::ASTCast>,
> eddic::ast::Deferred<eddic::ast::ASTBuiltinOperator>,
> eddic::ast::Deferred<eddic::ast::ASTAssignment>,
> eddic::ast::Deferred<eddic::ast::ASTSuffixOperation>,
> eddic::ast::Deferred<eddic::ast::ASTPrefixOperation>,
> eddic::ast::Deferred<eddic::ast::ASTTernary> >, 0> >,
> 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_,
> boost::detail::variant::void_>::has_fallback_type_; typename
> Visitor::result_type = void; mpl_::false_ = mpl_::bool_<false>]:
> Assertion `!"Boost.Variant internal error: 'which' out of range."'
> failed.

If I swap two elements (Ternary and New for example), New is correctly recognized, but not Ternary. It is only the last element that fails. 

I already tried using push_front or vector21, but it doesn't change anything, it's always the last element that have problem. In my opinion it comes from the fact that Spirit uses a variant internally before copying it to my variant_over type. 

Is there a workaround to this problem ? 

I could probably reduce the number to 20, but the problem is that I will certainly have more  than that in the future. 

Thanks a lot for any idea