Prev: SetMapMode and MouseMove messages
Next: Dumb C question
From: Vladimir Grigoriev on 18 Jan 2010 09:16 Why is not compiled the following code in Visual C++ 2005 EE? template <template <typename T, typename A> typename Container, typename T, typename A> inline typename Container<T, A>::size_type size( Container<T, A> &c ) { return ( c.size() ); } Vladimir Grigoriev
From: Victor Bazarov on 18 Jan 2010 09:25 Vladimir Grigoriev wrote: > Why is not compiled the following code in Visual C++ 2005 EE? > > template <template <typename T, typename A> typename Container, > typename T, typename A> > inline typename Container<T, A>::size_type size( Container<T, A> &c ) > { > return ( c.size() ); > } What does your question mean? Could you perhaps rephrase it? What do you expect, and why? What do you get? Post *complete* code and the compiler output and explain how it is different from what you expect. V -- Please remove capital 'A's when replying by e-mail I do not respond to top-posted replies, please don't ask
From: Vladimir Grigoriev on 18 Jan 2010 09:46 Victor I get the following errors ------ Build started: Project: lab_test, Configuration: Debug Win32 ------ Compiling... lab_test.cpp c:\documents and settings\vgrigoryev\my documents\visual studio 2005\projects\lab_test\lab_test.cpp(51) : error C2988: unrecognizable template declaration/definition c:\documents and settings\vgrigoryev\my documents\visual studio 2005\projects\lab_test\lab_test.cpp(51) : error C2059: syntax error : '<L_TEMPLATEDECL>' c:\documents and settings\vgrigoryev\my documents\visual studio 2005\projects\lab_test\lab_test.cpp(48) : error C2143: syntax error : missing ';' before '<' c:\documents and settings\vgrigoryev\my documents\visual studio 2005\projects\lab_test\lab_test.cpp(48) : error C2433: 'Container' : 'inline' not permitted on data declarations c:\documents and settings\vgrigoryev\my documents\visual studio 2005\projects\lab_test\lab_test.cpp(48) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\vgrigoryev\my documents\visual studio 2005\projects\lab_test\lab_test.cpp(48) : error C2988: unrecognizable template declaration/definition c:\documents and settings\vgrigoryev\my documents\visual studio 2005\projects\lab_test\lab_test.cpp(48) : error C2059: syntax error : '<' c:\documents and settings\vgrigoryev\my documents\visual studio 2005\projects\lab_test\lab_test.cpp(48) : error C2039: 'size_type' : is not a member of '`global namespace'' Build log was saved at "file://c:\Documents and Settings\vgrigoryev\My Documents\Visual Studio 2005\Projects\lab_test\Debug\BuildLog.htm" lab_test - 8 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Vladimir Grigoriev "Victor Bazarov" <v.Abazarov(a)comAcast.net> wrote in message news:hj1r10$f1n$1(a)news.datemas.de... > Vladimir Grigoriev wrote: >> Why is not compiled the following code in Visual C++ 2005 EE? >> >> template <template <typename T, typename A> typename Container, >> typename T, typename A> >> inline typename Container<T, A>::size_type size( Container<T, A> &c ) >> { >> return ( c.size() ); >> } > > What does your question mean? Could you perhaps rephrase it? What do you > expect, and why? What do you get? Post *complete* code and the compiler > output and explain how it is different from what you expect. > > V > -- > Please remove capital 'A's when replying by e-mail > I do not respond to top-posted replies, please don't ask
From: Igor Tandetnik on 18 Jan 2010 11:39 Vladimir Grigoriev wrote: > Why is not compiled the following code in Visual C++ 2005 EE? > > template <template <typename T, typename A> typename Container, > typename T, typename A> > inline typename Container<T, A>::size_type size( Container<T, A> &c ) > { > return ( c.size() ); > } You must use the keyword 'class', not 'typename', with template template parameters. template <template <typename T, typename A> class Container, typename T, typename A> inline typename Container<T, A>::size_type size( Container<T, A> &c ) { return ( c.size() ); } -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
From: Vladimir Grigoriev on 18 Jan 2010 11:51
Thanks, Igor. However the Standard if I am not mistaken says that there is no any difference of using typename and class when template parameters are defined, is there? Vladimir Grigoriev "Igor Tandetnik" <itandetnik(a)mvps.org> wrote in message news:eKlOZ2FmKHA.1536(a)TK2MSFTNGP06.phx.gbl... Vladimir Grigoriev wrote: > Why is not compiled the following code in Visual C++ 2005 EE? > > template <template <typename T, typename A> typename Container, > typename T, typename A> > inline typename Container<T, A>::size_type size( Container<T, A> &c ) > { > return ( c.size() ); > } You must use the keyword 'class', not 'typename', with template template parameters. template <template <typename T, typename A> class Container, typename T, typename A> inline typename Container<T, A>::size_type size( Container<T, A> &c ) { return ( c.size() ); } -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925 |