Topic: Template syntax (was: Template and Preprocessor)
Author: David Vandevoorde <daveed@vandevoorde.com>
Date: 1997/06/23 Raw View
Denis Vlasenko wrote:
[...]
> I think '<>' are nastiest kind of delimiters. < and > already have
> meaning of 'less than' and 'greater than'. Why () wasn't used instead?
>
> template (class T)
> class Class: public T {
> public:
> Class(T)(int);
> ...
> };
> ...
> Class(int) instance(5);
>
> Is there any problem with such approach?
Yes, it makes parsing (especially of member templates) hard:
template(int N)
struct X {
template(int M)
X(M) f();
}
void g() {
X(100) *x; // Multiplication or definition?
x->f(3)(); // You'll still want the `->template' hack
}
The use of braces seems very viable though. Apparently, this
had been proposed to the committee by a member with an extremely
strong reputation in programming language grammars and parsers.
I am surprised (and disappointed) that his advice was not
followed.
Daveed
---
[ 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 ]