Possible bug in mpl::push_front for vectorN

::algorithm<test, X>' /usr/include/boost/mpl/aux_/push_front_impl.hpp:31: error: declaration of `struct boost::mpl::push_front_traits<boost::mpl::aux::vector_tag<20l> ::algorithm<test, X>'
#define BOOST_MPL_LIMIT_VECTOR_SIZE 20 #include "boost/mpl/vector.hpp" #include "boost/mpl/push_front.hpp" class X { }; typedef boost::mpl::vector20< X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X > test; typedef boost::mpl::push_front< test, X >::type test2; int main() { return 0; } GCC Version 3.4.0 gives /usr/include/boost/mpl/push_front.hpp: In instantiation of `boost::mpl::push_front<test, X>': push_front.cpp:10: instantiated from here /usr/include/boost/mpl/push_front.hpp:36: error: invalid use of undefined type `struct boost::mpl::push_front_traits<boost::mpl::aux::vector_tag<20l> push_front.cpp:10: error: expected init-declarator before "test2" push_front.cpp:10: error: expected `,' or `;' before "test2"

Hamish Mackenzie writes:
#define BOOST_MPL_LIMIT_VECTOR_SIZE 20
You don't need to define BOOST_MPL_LIMIT_VECTOR_SIZE if you are using a numbered form ('vector20') -- you can just include the corresponding header directly, e.g. #include "boost/mpl/vector/vector20.hpp"
#include "boost/mpl/vector.hpp" #include "boost/mpl/push_front.hpp"
class X { };
typedef boost::mpl::vector20< X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X > test; typedef boost::mpl::push_front< test, X >::type test2;
This produces a vector with 21 elements; it will work for GCC (and other compilers with some kind of 'typeof') in the next release, however right now to be able to programmatically extend a 'vector' up to N elements you need to include the corresponding "vector(((N+9)/10)*10).hpp" header. In your case above it'll be "vector30.hpp". HTH, -- Aleksey Gurtovoy MetaCommunications Engineering
participants (2)
-
Aleksey Gurtovoy
-
Hamish Mackenzie