Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
June 28, 2003 malformed template with form g(f(x)) | ||||
---|---|---|---|---|
| ||||
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 |
June 29, 2003 Re: malformed template with form g(f(x)) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Richard Grant | 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? |
June 29, 2003 Re: malformed template with form g(f(x)) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christof Meerwald | 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 |
June 29, 2003 Re: malformed template with form g(f(x)) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Richard Grant | In article <bdn8d1$nf3$1@digitaldaemon.com> Richard Grant says... not very much ;) ok forget about that last post. And thanks for correction. Richard |
July 05, 2003 Re: malformed template with form g(f(x)) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Richard Grant | 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 > > |
Copyright © 1999-2021 by the D Language Foundation