Boost logo

Boost :

From: Ralf W. Grosse-Kunstleve (rwgk_at_[hidden])
Date: 2002-06-25 10:09:04


--- Samuel Krempp <krempp_at_[hidden]> wrote:
> On Thu, 2002-06-20 at 21:14, David Abrahams wrote:
>
> > suggested identity<> before; nobody seemed to get the whole metafunction
> > idea, so for the record, I don't care all that much what we call it.
>
> If I think of a "identity" metafunction, I would expect it to follow the
> properties of a regular identity :
> "x" is perfectly equivalent to "identity(x)"
>
> But here "T" is equivalent to "identity<T>::type",
> not just "identity<T>".
>
> For me, it's not identity.. it's a bijective metafunction all-right, but
> not identity.
> I thought injective metafunctions were usually called "wrappers" -and in
> fact those wrappers often are as much bijective as this identity<T>
> template. The difference is just that this one is intended to serve as
> as an identity metafunction. (since it's the closest we can get to such
> a thing. there is no "let f(T) = T" possible here..)
>
> So, personnally, I'd rather choose for a weaker, but correct, name based
> on 'wrapper',
> than a more precise, but slightly incorrect name based on 'identity'..
>
> ah, I thought of a clear manifestation of the difference between a true
> identity and this metafunction.
> Mathematically, identity composed with itself is still identity.
> So I'd expect
> identity< identity<T> > to be the exact same thing as
> identity<T>
> And, unless you add a specialisation, it's not the case.
>
>
> Still, the
> T operator()(T x) const { return x; }
> really is an identity.
> So if it's included in the struct, it could be named identity<T>, due to
> this function (rather than to the struct viewed as metafunction, which
> is *not* an identity).

I find Samuel's arguments very convincing. To add another thought: once there
are template typedef's you might want to use "identity" there. I am not
familiar with the proposed syntax, but let me guess:

template <typename T> typedef identity T;

But even here I'd prefer "identity_type" or "type_identity" .

To me, "type_wrapper<>" seems to be the most appropriate name for what is
currently called "type<>" .

Ralf

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com


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