Topic: Ambiguity in class template non-type default argument specification
Author: "Sanjay" <sanjayp@ddi.com>
Date: 1997/10/21 Raw View
Hi all,
If you define a class template as:
template <int i = 3>
class foo {
};
the '>' can cause ambiguity, because according to CD2, a template-parameter
is defined as:
template-parameter:
type-parameter
parameter-declaration
The parameter-declaration is the one for function parameters which accept
default argument
expressions. This expression can have a '>' operator. The standard should
add something to
remove this ambiguity, since it has done so in the other case of template
specializations
(see 14.2 para 3). The statement there says "...When parsing a template-id,
the first non-
nested > is taken as the end of the template-argument-list rather than a
greater-than
operator.". This clarifies cases such as:
template <int i> class X {};
X < (1>2) > x1; // ok
A similar clarification is needed for template-declaration.
Sanjay
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]