www.digitalmars.com         C & C++   DMDScript  

c++.beta - malformed template with form g(f(x))

reply Richard Grant <fractal clark.net> writes:
template <class T> struct A {};
template <class T> struct B {};
template <class T> A<B<T>> fn() { return A<B<T>>(); }

int main() {
//Error: malformed template declaration
fn<int>();
}

Richard
Jun 28 2003
parent reply Christof Meerwald <cmeerw web.de> writes:
On Sat, 28 Jun 2003 21:29:06 +0000 (UTC), Richard Grant wrote:
 template <class T> struct A {};
 template <class T> struct B {};
 template <class T> A<B<T>> fn() { return A<B<T>>(); }
should be: template <class T> A<B<T> > fn() { return A<B<T> >(); }
 int main() {
 //Error: malformed template declaration
 fn<int>();
 }
Well, the error message could be a bit clearer, but your code is not legal C++. bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net?
Jun 28 2003
parent reply Richard Grant <fractal clark.net> writes:
In article <bdm0cd$2jkm$1 digitaldaemon.com>, Christof Meerwald says...
On Sat, 28 Jun 2003 21:29:06 +0000 (UTC), Richard Grant wrote:
 template <class T> struct A {};
 template <class T> struct B {};
 template <class T> A<B<T>> fn() { return A<B<T>>(); }
should be: template <class T> A<B<T> > fn() { return A<B<T> >(); }
So the extra space helps identify the type? That's a little odd. But is in keeping with typeid having a space as I pointed out some time ago.
 int main() {
 //Error: malformed template declaration
 fn<int>();
 }
Well, the error message could be a bit clearer, but your code is not legal C++.
What is illegal about the code above? Richard
Jun 29 2003
parent reply Richard Grant <fractal clark.net> writes:
In article <bdn8d1$nf3$1 digitaldaemon.com>

Richard Grant says...
not very much ;)

ok forget about that last post. And thanks for correction.

Richard
Jun 29 2003
parent "Rajiv Bhagwat" <dataflow vsnl.com> writes:
The compiler uses "maximal munch" i.e.. grabs as many characters as possible
to form a token, and ">>" is a valid operator. So, to use <T> followed by
another >, you must leave a space in between.

Rajiv


"Richard Grant" <fractal clark.net> wrote in message
news:bdndm0$t6h$1 digitaldaemon.com...
 In article <bdn8d1$nf3$1 digitaldaemon.com>

 Richard Grant says...
 not very much ;)

 ok forget about that last post. And thanks for correction.

 Richard
Jul 05 2003