Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2003-01-30 16:00:37


>From: "Jason House" <jhouse_at_[hidden]>

> 2. Section 2.5 (Different Declarations) rubs me the wrong way. Thr
> proposal does say that some people dislike this, and I guess I'm one of
> them.
>
> If
> template <A,B> class X;
> template <A> typedef foo X<A,B>;
> then I'm opposed to typeof(X<A,B>) != typeof(foo<A>)

As I understand the proposal, template typedefs will yield the same type,
not a new type. The template typedef, _in itself_ (i..e. its definition) is
not an alias to an existing template, but an instantiation (i.e. use of it)
yields an alias of an existing type. Therefore, template typedefs don't
introduce new types.

typeof(X<A,B>) == typeof(foo<A>)

> After all
> if
> typedef bar int;
> then typeof(bar) == typeof(int) /* causes occasional dismay */
>
> I'd like to see templates hold the same logical niche for both templated
> and untemplated types.

They do. :)

What makes the template typedef proposal different from the template alias
proposal, is that the former may be specialised, and the latter may be
deduced.

> It would be interesting to have a means of defining a new type via a
> typedef-like declaration that did not share type equality, I just
> wouldn't want it to be a normal looking typedef statement.

There has been suggestions for this, e.g. something like this:

typedef new int new_int;

typeof(int) != typeof(new_int)

This wouldn't introduce new keywords, either.

Regards,

Terje


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