Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-11-28 15:28:14


On Wednesday, November 28, 2001, at 03:15 PM, Mark Rodgers wrote:

> From: "David Abrahams" <david.abrahams_at_[hidden]>
>
>> FWIW, I'm back to liking int_wrapper and type_wrapper ;-/.
>
> I certainly agree that we need an identity metafunction so I
> like that name for the template when it is being used in that
> role. However the same template can be used for other things
> as demonstrated by Andrei, and for this identity is probably
> not appropriate.

And in any case, a more flexible way to write it as a function uses a
nested class template formulation...

> But I certainly don't like type2type either. "Converts each
> type into a unique, insipid type" is pretty meaningless to me.
> What is an insipid type? Why do we need to "convert" the type
> to another type - it's already a type.
>
> type_wrapper is definitely a better choice, so we could either
> do this:
>
> template <typename T>
> struct type_wrapper
> {
> typedef T type;
> };
>
> template <typename T>
> struct identity : type_wrapper<T> {};

I'd prefer to use the nested template formulation for metafunctions.

> or just duplicate the code since it is so simple.
>
> As far as int2type is concerned, I agree with Aleksey's
> arguments in favour of brevity and think int_t is best.

as long as we're tinkering with names, consider "value_t" or
"value_type":

template <typename T, T x>
struct value_t
{
        static T const value = x;
};

template <int x>
struct int_t : value_t<int, x> {};

Did somebody already suggest that?


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