|
Boost Users : |
Subject: Re: [Boost-users] Using an mpl sepquence as a template parameter
From: paul Fultz (pfultz2_at_[hidden])
Date: 2011-11-14 17:28:54
Thanks for the help. After digging around, it seems I can define the two macros like this:
#define MPL_VECTOR_PACK(x) BOOST_MPL_PP_DEFAULT_PARAMS(BOOST_MPL_LIMIT_VECTOR_SIZE, x, boost::mpl::na)
#define MPL_VECTOR_UNPACK(x) BOOST_MPL_PP_PARAMS(BOOST_MPL_LIMIT_VECTOR_SIZE, x)
Except as you say this uses an implementation detail. It would be nice if they added some macros like these in the future, to get semi support for varidiac parameters in older compilers.
>I think there are a number of ways to do this. One might be to take advantage of boost::mpl::na, though it looks like technically an implementation >detail so its stability could be questionable (defined in <boost/mpl/aux_/na_fwd.hpp>, I believe). For example:
>
>template< class T0 = boost::mpl::na, class T1 = boost::mpl::na, class T2 = boost::mpl::na, [and so on...] >
>struct X
>{
> typedef boost::mpl::vector< T0, T1, T2, [and so on...] > type;
>};
>
>You can use the Boost.Preprocessor library, e.g., BOOST_PP_ENUM_PARAMS and BOOST_PP_ENUM_BINARY_PARAMS, to make this a lot >less repetitious.
>
>- Jeff
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