templated type as template type?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: templated type as template type?

  1. #1
    Join Date
    Mar 2009
    Posts
    18

    Question templated type as template type?

    This question has probably come up before but I can't find an answer.

    Why can't I declare something like:
    Code:
    TemplatedClassA<TemplatedClassB<int>> myFancyVariable;
    The compiler refuses to recognize the syntax:
    error: ISO C++ forbids declaration of 'TemplatedClassA' with no type
    error: expected ';' before '<' token

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,266

    Re: templated type as template type?

    You can, in the next version of C++. For now:
    Code:
    TemplatedClassA<TemplatedClassB<int> > myFancyVariable;
    to avoid greedy matching of >>
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Mar 2009
    Posts
    18

    Unhappy Re: templated type as template type?

    It still doesn't compile. I get the same errors. My compiler is g++ 4.4.1.

  4. #4
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,266

    Re: templated type as template type?

    Post the smallest and simplest program that you think should compile but which results in the compile error that you are currently trying to fix.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  5. #5
    Join Date
    Mar 2009
    Posts
    18

    Re: templated type as template type?

    No, I'm sorry, "> >" did work ;-)

  6. #6
    Join Date
    May 2009
    Posts
    2,413

    Re: templated type as template type?

    Quote Originally Posted by ssouffri View Post
    No, I'm sorry, "> >" did work ;-)
    This C++ bug (or embarrassment as Stroustrup prefers to call it ) is fixed in the next version.

  7. #7
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,266

    Re: templated type as template type?

    Quote Originally Posted by ssouffri
    No, I'm sorry, "> >" did work ;-)
    Good to hear I must say that the error message is a little puzzling though. Reading it again, I would have expected a different error message.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center