Boost.Tuple extension *style* question

Alan M. Carroll wrote:
The previous message reminded me of something I wanted to ask.
I wrote an extension for Boost.Tuple that, given a type T and a Boost N-tuple, computes the N+1 tuple (this turns out to be handy for my application). The basic definition looks like this:
template < typename R, typename T, int N = 0 > struct add_type { typedef typename add_type< typename R, typename T, length< typename T>::value >::type type; };
There's a bunch of specializations that handle the actual implementation that are obvious specializations for non-zero values of N.
It's used like this:
typedef typename add_type
::type region where "interval" is the type we want to prepend in to the tuple and "super::region" is the existing tuple. So if super::region is tuple then region is tuple
. Now, the actual style question: Should I have made the add_type be (stylistically) a Boost.MPL metafunction instead? E.g., a metafunction of two arguments (type, tuple) that produces the result tuple? Is that the common practice? Or is that only done when intending to use Boost.MPL? That would mean tthe usage (regardless of whether Boost.MPL itself was in use) would be
typedef typename add_type_mf::apply
::type region; Is that preferred (as in, a little more wordy but much clearer because of the convention)?
You need both a function and a metafuncion. In fusion, you
have this functions:
push_back(tup, x);
push_front(tup, x);
and its corresponding metafunction:
meta::push_back
participants (2)
-
Alan M. Carroll
-
Joel de Guzman