Topic: Ambiguity of >> in default template-argument
Author: Michael Doubez <michael.doubez@free.fr>
Date: Fri, 19 Mar 2010 14:29:40 CST Raw View
Hi,
I have noticed that there is an entry for the ambiguity of > as
greater-than operator in default template-argument (=A714.2/13) but
there is none for >> as shift-right operator. While both cases
requires parentheses for template specialization (=A714.3/3).
Does it mean that >> is not ambiguous when used as default template
argument.
As in:
template< int i , class T = Bar< i>>2 >> Foo;
Or is it implicit. Is there a specific reason for that ?
--
Michael
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use
mailto:std-c++@netlab.cs.rpi.edu<std-c%2B%2B@netlab.cs.rpi.edu>
]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Fri, 19 Mar 2010 18:08:30 CST Raw View
On 19 Mrz., 21:29, Michael Doubez <michael.dou...@free.fr> wrote:
> I have noticed that there is an entry for the ambiguity of > as
> greater-than operator in default template-argument (=A714.2/13) but
> there is none for >> as shift-right operator. While both cases
> requires parentheses for template specialization (=A714.3/3).
>
> Does it mean that >> is not ambiguous when used as default template
> argument.
It is ambiguous, see below.
> As in:
> template< int i , class T = Bar< i>>2 >> Foo;
>
> Or is it implicit. Is there a specific reason for that ?
It follows from 14.3/3, because name lookup is
used to detect whether Bar<i> is a template.
In fact the example given in that paragraph
applies to the default template parameter
as well:
Y<X<6>>1>> x4; // syntax error
Y<X<(6>>1)>> x5; // OK
Note that the special syntax rule of 14.2/13
is only relevant for non-type template parameters:
"When parsing a default template-argument for a
non-type template-parameter, the first non-nested >
is taken as the end of the template-parameter-list
rather than a greater-than operator."
but in your example the non-type template
parameter i is not affected, because it doesn't
have a default template argument.
HTH & Greetings from Bremen,
Daniel Kr gler
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Sat, 20 Mar 2010 14:35:32 CST Raw View
On 20 Mrz., 01:08, Daniel Kr gler <daniel.krueg...@googlemail.com>
wrote:
> On 19 Mrz., 21:29, Michael Doubez <michael.dou...@free.fr> wrote:
>
> > I have noticed that there is an entry for the ambiguity of > as
> > greater-than operator in default template-argument (=A714.2/13) but
> > there is none for >> as shift-right operator. While both cases
> > requires parentheses for template specialization (=A714.3/3).
>
> > Does it mean that >> is not ambiguous when used as default template
> > argument.
>
> It is ambiguous, see below.
More precisely: The syntax is incorrect.
Greetings from Bremen,
Daniel Kr gler
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]