Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2001-11-29 01:26:21


on 11/28/01 8:15 PM, Mark Rodgers at mark.rodgers_at_[hidden] 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.
>
> 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> {};
>
> 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.

I think others have said that "int_t" isn't descriptive enough. I think
there is a similarly named class template in <boost/integer.hpp> that does
something totally unrelated. What about "int_as_type"?

template < int V >
struct int_as_type
{
    static int const value = V;
};

Or, being more general (for bool, unsigned, enum[?], etc.)

template < typename T, T V >
struct discrete_as_type
{
    typedef T type;

    static type const value = V;
};

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

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