Boost logo

Boost :

From: David A. Greene (greened_at_[hidden])
Date: 2002-12-05 11:55:33

[Posted to boost because MPL is not yet released. At what
  point should these questions go to boost-users?]

Say I have a type my_type:

template<typename T, typename U, typename V>
struct my_type { ... }

Now let's say I want to create a generator that
binds T to some type but leaves U and V free to
be filled in later. Basically, I want something
like this:

template<typename Bound>
struct my_type_generator {
    template<typename U, typename V>
    struct apply {
       typedef my_type<Bound, U, V> type;

Is there a convenient way to create this with MPL? I
thought lambda might do the trick, but apparently not:

typedef my_type<int, mpl::_1, mpl::_2> my_type_generator;

(This will be passed to an MPL algorithm so I didn't
bother with lambda<>).

This causes a static assertion in mpl::arg<2> where it
sees a void type for V (I think).

Is the problem that my_type doesn't contain a ::type
member? my_type is not a metafunction so maybe it just
can't be used conveniently with mpl. It's easy enough
to manually define my_type_generator, but I think this
is a pretty common pattern and it might be useful as a
library component.


"Some little people have music in them, but Fats, he was all music,
  and you know how big he was."  --  James P. Johnson

Boost list run by bdawes at, gregod at, cpdaniel at, john at