Boost logo

Boost :

From: wb_at_[hidden]
Date: 2001-11-26 17:20:32


Just as another source of ideas for these important constructs,
I attach a lightly-edited excerpt from SIunits' "metatypes" header
for consideration.

        - WEB

// ---------- begin excerpt ----------

namespace meta {

template< class T >
struct type_is // previous names: type_wrapper, my_type
{
  typedef T type;
}

template< class T, T v >
struct value_is // previous names: value_wrapper, my_value
  : public type_is<T>
{
  static T const value = v;
}

} // namespace meta

// ---------- end excerpt ----------

David Abrahams <david.abrahams_at_[hidden]> wrote on Mon Nov 26 15:36:16 2001:

| Too bad we can't overload compile-time functions; then we could have
| identity<10>::value == 10 and identity<char>::type == type.
|
| Maybe value_identity is best... leading to type_identity for symmetry :-/
|
| ----- Original Message -----
| From: "joel de guzman" <djowel_at_[hidden]>
|
| > ----- Original Message -----
| > From: "Andrei Alexandrescu" :
| >
| > > From: "David Abrahams" <david.abrahams_at_[hidden]>
| > > > BTW, isn't "identity" a much better name than "type2type"?
| > >
| > > Identity sounds great, I'll make that change unless there is a lot of
| > > opposition.
| >
| > identity is cool!
| >
| > int2type and type2type are quite, umm, unclear.
| >
| > How about static_int<N> instead of int2type<N> ? Syntactically, It's like
| > static_cast that transforms an int to a distinct static-integer type.
| >
| > Or maybe, how about: int_identity<N> ?
<snip>


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