C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

template typedef

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Frank Birbacher
Guest





PostPosted: Fri Oct 08, 2004 5:37 pm    Post subject: template typedef Reply with quote



Hi!

Is there already a proposal for templated typedefs?

I thing it would be useful to do something like:

template<typename T1, typename T2>
struct Foo {};

template<typename T>
typedef Foo<T,T> Bar;

If this was allowed one could typedef a vector to vector1 and use
vector1 as a template<typename> parameter:

template<template
struct WhatEver {...};

template<typename T>
typedef std::vector<T> vector1;

WhatEver<vector1> values;

Of course, there are ways to work around this problem:

struct container_function
{
template<typename T>
struct get_container
{
typedef std::vector<T> value;
};
};

template<typename ContainerFunc>
struct WhatEver {...};

WhatEver<container_function> bar;

But that doesn't look nice.

So I'd like to have templated typedef added to the next standard.

Frank

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]

Back to top
Ben Hutchings
Guest





PostPosted: Mon Oct 11, 2004 4:12 pm    Post subject: Re: template typedef Reply with quote



Frank Birbacher wrote:
Quote:
Hi!

Is there already a proposal for templated typedefs?
snip


There has been a proposal for template aliases which could be used
for types, though using the "using" keyword rather than "typedef":

Gabriel Dos Reis and Mat Marcus, Proposal to add template aliases to C++
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1449.pdf>

This was expanded in

Bjarne Stroustrup and Gabriel Dos Reis, Template aliases for C++
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1489.pdf>

--
Ben Hutchings
Lowery's Law:
If it jams, force it. If it breaks, it needed replacing anyway.

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Frank Birbacher
Guest





PostPosted: Tue Oct 12, 2004 9:57 pm    Post subject: Re: template typedef Reply with quote



Hi!

Ben Hutchings wrote:
Quote:
Gabriel Dos Reis and Mat Marcus, Proposal to add template aliases to C++
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1449.pdf

Yes, it's what I mean. But I wonder why they prefer
template<typename T>
using Vec = MyVector<T, MyAlloc
instead of the more intuitive (at least to me):
template<typename T>
typedef MyVector<T, MyAlloc Vec;
Where 'typedef' usually introduces aliases for types. I couldn't
understand the explanation in the proposal. Can anyone shed some
light?

Frank

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Gabriel Dos Reis
Guest





PostPosted: Wed Oct 13, 2004 5:12 am    Post subject: Re: template typedef Reply with quote

[email]bloodymir.crap (AT) gmx (DOT) net[/email] (Frank Birbacher) writes:

Quote:
Hi!

Ben Hutchings wrote:
Gabriel Dos Reis and Mat Marcus, Proposal to add template aliases to C++
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1449.pdf

Yes, it's what I mean. But I wonder why they prefer
template<typename T
using Vec = MyVector instead of the more intuitive (at least to me):
template typedef MyVector Vec;
Where 'typedef' usually introduces aliases for types. I couldn't
understand the explanation in the proposal. Can anyone shed some light?

Reasons are given in both papers. For example, Vec is not a type so
using "typedef" in that context is misleading (one could argue that
"typedef" is already misnamed but we did not feel an urgent pressure
to add more confusion). Also "typedef" does not generalize to other
aliasing constructs, as noted in the second paper.

And the second paper discusses the choice of "using".

--
Gabriel Dos Reis
[email]gdr (AT) cs (DOT) tamu.edu[/email]
Texas A&M University -- Computer Science Department
301, Bright Building -- College Station, TX 77843-3112

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
John Max Skaller
Guest





PostPosted: Mon Oct 18, 2004 10:23 pm    Post subject: Re: template typedef Reply with quote

On Wed, 13 Oct 2004 05:12:04 +0000, Gabriel Dos Reis wrote:

Quote:
bloodymir.crap (AT) gmx (DOT) net (Frank Birbacher) writes:

| Yes, it's what I mean. But I wonder why they prefer
| template<typename T
| using Vec = MyVector | instead of the more intuitive (at least to me):
| template | typedef MyVector Vec;
| Where 'typedef' usually introduces aliases for types. I couldn't
| understand the explanation in the proposal. Can anyone shed some light?

Reasons are given in both papers. For example, Vec is not a type so
using "typedef" in that context is misleading (one could argue that
"typedef" is already misnamed but we did not feel an urgent pressure
to add more confusion). Also "typedef" does not generalize to other
aliasing constructs, as noted in the second paper.

And the second paper discusses the choice of "using".

Another reason is new syntax can have new lookup rules,
in particular in the case

using X = list<X>

can deem X comes into scope at the = sign.
That seems useful since C supports type recursion
easily .. but templates do not.

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Mark Williams
Guest





PostPosted: Mon Oct 18, 2004 11:25 pm    Post subject: Re: template typedef Reply with quote

[email]gdr (AT) cs (DOT) tamu.edu[/email] (Gabriel Dos Reis) wrote in message news:<m3655f6z5e.fsf (AT) merlin (DOT) cs.tamu.edu>...
Quote:
bloodymir.crap (AT) gmx (DOT) net (Frank Birbacher) writes:

| Hi!
|
| Ben Hutchings wrote:
| > Gabriel Dos Reis and Mat Marcus, Proposal to add template aliases to C++
| > <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1449.pdf
|
| Yes, it's what I mean. But I wonder why they prefer
| template | using Vec = MyVector | instead of the more intuitive (at least to me):
| template | typedef MyVector Vec;
| Where 'typedef' usually introduces aliases for types. I couldn't
| understand the explanation in the proposal. Can anyone shed some light?

Reasons are given in both papers. For example, Vec is not a type so
using "typedef" in that context is misleading

Im missing something.

A function template is not a function; a class template is not a
class; why would anyone expect a typedef template to be a type?

Mark Williams

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Alberto Barbati
Guest





PostPosted: Tue Oct 19, 2004 4:42 am    Post subject: Re: template typedef Reply with quote

Frank Birbacher wrote:
Quote:
Hi!

Ben Hutchings wrote:

Gabriel Dos Reis and Mat Marcus, Proposal to add template aliases to C++
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1449.pdf


Yes, it's what I mean. But I wonder why they prefer
template<typename T
using Vec = MyVector instead of the more intuitive (at least to me):
template typedef MyVector Vec;
Where 'typedef' usually introduces aliases for types. I couldn't
understand the explanation in the proposal. Can anyone shed some light?


I think I understood the difference after reading the (real) typedef
template proposal:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1406.pdf

A typedef template is clearly not a typedef, as many have understood,
but its *instatiations* are typedefs. So a typedef template effectively
introduces a parametrized family of aliases each one representing a type.

OTOH, a template alias (notice that inversion: it's not "alias template"
intentionally!) introduce just *one* single alias that represents a
template.

The alias approach has a few advantages, clearly described in both
papers. In particular:

* deduction works for template aliases
* template aliases can be used as template template parameters

The cost is that a template alias cannot be specialized, but paper N1449
shows that this limitation is easily overcome using traits classes.

Hope I understood it correctly... ;-)

Alberto

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Frank Birbacher
Guest





PostPosted: Thu Oct 21, 2004 1:55 am    Post subject: Re: template typedef Reply with quote

Hi!

Mark Williams wrote:
Quote:
Reasons are given in both papers. For example, Vec is not a type so
using "typedef" in that context is misleading


Im missing something.

A function template is not a function; a class template is not a
class; why would anyone expect a typedef template to be a type?

I agree, Mark. To me using 'template<...> typedef' seems most
natural. Alberto Barbati said so, too.

The word 'using' seems appropirate after reading the proposals.
But writing

struct Foo1
{
template<typename T>
using ArrayType = std::vector<T>;
//...
};

looks more like an implementation detail. And it has other
semantics as:

struct Foo2
{
using std::vector;
//...
};

because 'Foo1::ArrayType' may be used as a template template
parameter, whereas 'Foo2::vector' may not. So instead of 'using'
an existing type, you 'define' a new name for an existing type.
Therefore use 'typedef'.

Frank

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Gabriel Dos Reis
Guest





PostPosted: Sat Oct 23, 2004 4:37 pm    Post subject: Re: template typedef Reply with quote

[email]kmarkw65 (AT) yahoo (DOT) com[/email] (Mark Williams) writes:

Quote:
gdr (AT) cs (DOT) tamu.edu (Gabriel Dos Reis) wrote in message news:<m3655f6z5e.fsf (AT) merlin (DOT) cs.tamu.edu>...
[email]bloodymir.crap (AT) gmx (DOT) net[/email] (Frank Birbacher) writes:

| Hi!
|
| Ben Hutchings wrote:
| > Gabriel Dos Reis and Mat Marcus, Proposal to add template aliases to C++
| > <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1449.pdf
|
| Yes, it's what I mean. But I wonder why they prefer
| template | using Vec = MyVector | instead of the more intuitive (at least to me):
| template | typedef MyVector Vec;
| Where 'typedef' usually introduces aliases for types. I couldn't
| understand the explanation in the proposal. Can anyone shed some light?

Reasons are given in both papers. For example, Vec is not a type so
using "typedef" in that context is misleading

Im missing something.

A function template is not a function; a class template is not a
class; why would anyone expect a typedef template to be a type?

Because people are expecting class templates to work as classes?
And that leads to many confusions.

I do not want a new useful feature reinforces those confusions.
Plus, the "using" syntax, as extensively explained in the papers,
leads itself to more generality -- overloade set for example -- than
the "typedef" syntax. Plus, again as explained in the papers, it
cleans up the typedef syntax.

--
Gabriel Dos Reis
[email]gdr (AT) cs (DOT) tamu.edu[/email]
Texas A&M University -- Computer Science Department
301, Bright Building -- College Station, TX 77843-3112

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Alberto Barbati
Guest





PostPosted: Mon Oct 25, 2004 6:21 pm    Post subject: Re: template typedef Reply with quote

Frank Birbacher wrote:
Quote:

I agree, Mark. To me using 'template<...> typedef' seems most natural.
Alberto Barbati said so, too.


I said so? Don't remember...

The "typedef" syntax leads naturally to the notion of template typedef,
while the "using" syntax leads also naturally to the notion of template
alias. I remember I said that those two notions are radically different.

Quote:
The word 'using' seems appropirate after reading the proposals. But writing

struct Foo1
{
template<typename T
using ArrayType = std::vector //...
};

looks more like an implementation detail. And it has other semantics as:

struct Foo2
{
using std::vector;
//...
};

because 'Foo1::ArrayType' may be used as a template template parameter,
whereas 'Foo2::vector' may not. So instead of 'using' an existing type,
you 'define' a new name for an existing type.

It's not that Foo2::vector may not be used as a template parameter. As
using-declarations at class-scope are member-declarations, it's more
correct to say that your second example is ill-formed. This particular
case is not being addressed in N1489, but, for consistency, I expect the
first example to be deemed ill-formed too. Maybe a clarification on this
topic should be included in the paper.

That's in fact a very interesting point, because if template aliases are
illegal at class scope it would mean that they can't be used to address
the "allocator rebind" pattern, thus severely limiting their usefulness.
On the other hand, I agree with you that allowing template aliases at
class scope but not "simple" aliases would be inconsistent.

Quote:
Therefore use 'typedef'.

Don't be so hasty. Both approaches have pros and cons. Personally, I
still haven't decided which one is better. Before writing this post I
would have favored aliases over typedefs, but the class-scope issue is
now giving me a headache. I'm starting to think that we should have
both... ;-)

Regards,

Alberto

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Alberto Barbati
Guest





PostPosted: Tue Oct 26, 2004 7:36 pm    Post subject: Re: template typedef Reply with quote

Alberto Barbati wrote:
Quote:
Frank Birbacher wrote:

The word 'using' seems appropirate after reading the proposals. But
writing

struct Foo1
{
template<typename T
using ArrayType = std::vector //...
};

looks more like an implementation detail. And it has other semantics as:

struct Foo2
{
using std::vector;
//...
};

because 'Foo1::ArrayType' may be used as a template template
parameter, whereas 'Foo2::vector' may not. So instead of 'using' an
existing type, you 'define' a new name for an existing type.


It's not that Foo2::vector may not be used as a template parameter. As
using-declarations at class-scope are member-declarations, it's more
correct to say that your second example is ill-formed. This particular
case is not being addressed in N1489, but, for consistency, I expect the
first example to be deemed ill-formed too. Maybe a clarification on this
topic should be included in the paper.

That's in fact a very interesting point, because if template aliases are
illegal at class scope it would mean that they can't be used to address
the "allocator rebind" pattern, thus severely limiting their usefulness.
On the other hand, I agree with you that allowing template aliases at
class scope but not "simple" aliases would be inconsistent.

I just realized that the two syntaxes are completely different and so
they are not required to be consistent with each other. In particular:

template<typename T>
using ArrayType = std::vector<T>;

is a (templated) alias-declaration. As clearly stated in N1489: "an
alias-declaration is acceptable anywhere a typedef declaration or a
namespace-alias-definition is acceptable." Therefore this example is
(proposed to be) perfectly legal.

On the other hand:

using std::vector;

is a using-declaration, which is a completely different thing, so the
comparison is unfair. If there is an inconsistency issue, it is within
the notion of using-declaration itself as the semantic changes depending
on whether it's used at namespace scope or at class scope. However, I
don't think this issue is detrimental to the notion of alias-declaration.

To be fair, the comparison should have been with:

using vector = std::vector;

Unfortunately this is not currently covered by N1489 because it defines
alias-declaration as:

alias-declaration:
using identifier = type-id
using identifier = qualified-namespace-specified

However the section 2.3 of the paper seems to hint that a (possibly
qualified) template-name could also be used on the right side of '=', so
I believe that such syntax should be legal in the proposal's intentions.

Please notice that in the very same section it is stated that:

using std::ostream;

would be just a short-hand for

using ostream = std::ostream;

but we just saw that this is not going to be true in a class-scope and
the proposal should have warned about this difference.

Quote:

Therefore use 'typedef'.


Don't be so hasty. Both approaches have pros and cons. Personally, I
still haven't decided which one is better. Before writing this post I
would have favored aliases over typedefs, but the class-scope issue is
now giving me a headache. I'm starting to think that we should have
both... Wink

Faith in using/alias restored. ;-)

Alberto

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Gabriel Dos Reis
Guest





PostPosted: Tue Oct 26, 2004 9:13 pm    Post subject: Re: template typedef Reply with quote

[email]AlbertoBarbati (AT) libero (DOT) it[/email] (Alberto Barbati) writes:

Quote:
Frank Birbacher wrote:
I agree, Mark. To me using 'template<...> typedef' seems most
natural. Alberto Barbati said so, too.


I said so? Don't remember...

The "typedef" syntax leads naturally to the notion of template
typedef, while the "using" syntax leads also naturally to the notion
of template alias. I remember I said that those two notions are
radically different.

Notice that you can express the "typedef template" part in the
template alias framework. The papers contain examples of such.

Quote:
The word 'using' seems appropirate after reading the proposals. But writing
struct Foo1
{
template<typename T
using ArrayType = std::vector //...
};
looks more like an implementation detail. And it has other semantics
as:
struct Foo2
{
using std::vector;
//...
};
because 'Foo1::ArrayType' may be used as a template template
parameter, whereas 'Foo2::vector' may not. So instead of 'using' an
existing type, you 'define' a new name for an existing type.

It's not that Foo2::vector may not be used as a template parameter. As
using-declarations at class-scope are member-declarations, it's more
correct to say that your second example is ill-formed. This particular
case is not being addressed in N1489, but, for consistency, I expect
the first example to be deemed ill-formed too. Maybe a clarification
on this topic should be included in the paper.

Most certainly.

The paper suggested an alternate syntax for typedefs:

typedef int (*sig_t)(int);

could be written as

using sig_t = int (*)(int);

which follows from the suggested production:

alias-declaration:
using identifier = type-id;

and the template alias declaration grammar follows from the general
(existing) template declaration

export(opt) template< template-parameter-list(opt) > declaration


It is also explained, in the papers, that the existing using-declaration

using-declaration:
using typename(opt) ::(opt) nested-name-specified unqualified-id ;
using :: unqualified-id ;


is an alias declaration where the syntax has been optimized in the
sense that the alias name is just the unqualified part of the aliasee.


So the syntax suggested in the papers is no way conflicting with
existing syntaxes; rather it generalizes them.

AS it currently stands, the declaration at Foo2 scope is ill-formed in
both C+03 and C++0x (assuming template aliases are adopted) for
various reasons:
(1) in C++02, it is ill-formed because std::vector is not a base of
Foo2;
(2) in C++0x, it will be ill-formed because std::vector is not a type-id.


If a more general alias mechanism is adopted (something NOT proposed
by the papers), then it would make sense to remove the restrictions in
(2).

Quote:
That's in fact a very interesting point, because if template aliases
are illegal at class scope it would mean that they can't be used to
address the "allocator rebind" pattern, thus severely limiting their
usefulness. On the other hand, I agree with you that allowing template
aliases at class scope but not "simple" aliases would be inconsistent.

I see no reason why template aliases should be ill-formed at
class-scopes, given the connection between the alias-declaration and
using-declarations.

What you call "simple" aliases requires a much more general aliasing
mechanism and is not just that "simple" Smile.

As a matter of fact, it could be expressed with the template alias
syntax.

Quote:
Therefore use 'typedef'.

Don't be so hasty. Both approaches have pros and cons. Personally, I
still haven't decided which one is better. Before writing this post I
would have favored aliases over typedefs, but the class-scope issue is
now giving me a headache. I'm starting to think that we should have
both... Wink

The template alias framework already allows you to express typedef
templates. In many cases, they seem to be same; they differ when it
comes to specializations.

--
Gabriel Dos Reis
[email]gdr (AT) cs (DOT) tamu.edu[/email]
Texas A&M University -- Computer Science Department
301, Bright Building -- College Station, TX 77843-3112

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Frank Birbacher
Guest





PostPosted: Tue Oct 26, 2004 10:21 pm    Post subject: Re: template typedef Reply with quote

Hi!

Alberto Barbati wrote:
Quote:
Frank Birbacher wrote:


I agree, Mark. To me using 'template<...> typedef' seems most natural.
Alberto Barbati said so, too.


I said so? Don't remember...

Hmm, I must have missed you point then.

Quote:
That's in fact a very interesting point, because if template aliases are
illegal at class scope it would mean that they can't be used to address
the "allocator rebind" pattern, thus severely limiting their usefulness.

Hmm, I will have to read over the proposals once again. I think I
have missed a major point.

Quote:
On the other hand, I agree with you that allowing template aliases at
class scope but not "simple" aliases would be inconsistent.

I'm not aware of having made that point. But well, if it inspires
you... :)

Quote:
I'm starting to think that we should have
both... Wink

It's getting weird for me. You are starting to give me headaches.

Frank

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Gabriel Dos Reis
Guest





PostPosted: Wed Oct 27, 2004 5:37 am    Post subject: Re: template typedef Reply with quote

[email]AlbertoBarbati (AT) libero (DOT) it[/email] (Alberto Barbati) writes:

[...]

Quote:
On the other hand:

using std::vector;

is a using-declaration, which is a completely different thing, so the
comparison is unfair. If there is an inconsistency issue, it is within
the notion of using-declaration itself as the semantic changes depending
on whether it's used at namespace scope or at class scope.

Indeed.

The apparant discrepency in the meaning of using-declaration at
class-scope or namespace-scope can be reconciled in the framework of
alias-declaration; we do not propose it because we do not believe at
this point that a general alias notion is needed.

Remember that it takes a special rule to ban a using-declaration at
class that does not refer to a base-class member. Such a delcaratin
does not introduce a new-data member nor does it introduce a new
member function. Rather, it brings the name in scope, and optionally
adjust access control, as an alias (7.3.3/1).

At the intersection, at class-scope, of the new alias-declaration and
existing using-declaration lies using-declarations that nominates
type-names. Again, there is no conflict.

Quote:
However, I
don't think this issue is detrimental to the notion of alias-declaration.

To be fair, the comparison should have been with:

using vector = std::vector;

Unfortunately this is not currently covered by N1489 because it defines
alias-declaration as:

alias-declaration:
using identifier = type-id
using identifier = qualified-namespace-specified

Indeed.

Quote:
However the section 2.3 of the paper seems to hint that a (possibly
qualified) template-name could also be used on the right side of '=', so
I believe that such syntax should be legal in the proposal's intentions.

That is what I keep referring to as "a general notion of aliasing".
There is something to be said about it; D&E has a dicussion about that.

Quote:
Please notice that in the very same section it is stated that:

using std::ostream;

would be just a short-hand for

using ostream = std::ostream;

but we just saw that this is not going to be true in a class-scope and
the proposal should have warned about this difference.

That will be made explicit in standardese for this fonctionality.

However, notice that you can't write, in current C++,

using std::ostream;

at class-scope. So it was implicitly assumed that the above rewrite
was for the case where the "optimized" version is already allowed.


--
Gabriel Dos Reis
[email]gdr (AT) cs (DOT) tamu.edu[/email]
Texas A&M University -- Computer Science Department
301, Bright Building -- College Station, TX 77843-3112

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.