Boost logo

Boost :

From: Alberto Ganesh Barbati (abarbati_at_[hidden])
Date: 2005-11-11 04:13:23


Kevin Sopp wrote:
>
> Given a type T which is a model of MPL lambda expression, permute<T,
Args1,
> ..., ArgsN>::type is an MPL vector that contains all possible permutations
> of type T, where ArgsN is a model of an MPL forward sequence.
>
> Example:
> template<class X, class Y>
> struct base{};
>
> permute<
> base<_1,_2>, vector<int, float>, vector<double, bool>
>
>>::type types;
>
>
> types is an MPL vector containing all possible permutations of base with the
> supplied argument lists:
> vector<
> base<int,double>,
> base<int,bool>,
> base<float,double>,
> base<float,bool>
>
> (not necessarily in this order)

I'm sorry I'm not an MPL expert so I can't give you feedback about the
usefulness of this class. It looks interesting though. What I would like
to say is that you should choose a name different from "permute" because
it is misleading. From the wikipedia: "The concept of a permutation
expresses the idea that distinguishable objects may be arranged in
various different orders." In other words "permute" conveys the concept
that you already have a list of types and you provide a different
re-ordering of such list (compare with std::next_permutation,
std::last_permutation). In your case you are synthesizing a list of
types based on a sort of "template" type and a set of sets of
parameters. Moreover you say that the synthesized list has no particular
order. This looks a very different operation to me.

Just my opinion,

Ganesh


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk