CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2011
    Location
    Cosenza,Italy
    Posts
    62

    Typedef a template

    Hello! Not all the compilers accept:

    template <class T>
    Class1 < Class2 <T> > (for the confusion of > and >> symbols)

    I've tried to do a typedef in this way:

    typedef Class1 <T> class;
    But typedef a template is forbidden in C++.. So, how can I typedef a template, for using it in another template, in a way that the compiler won't give me an error? This is the code:
    Code:
    template <class T>
    class Matrice: public Vettore < Vettore <T> >
    { [...]
    }

  2. #2
    Join Date
    Jun 2008
    Posts
    592

    Re: Typedef a template

    Quote Originally Posted by Falko-tux
    Hello! Not all the compilers accept:

    template <class T>
    Class1 < Class2 <T> > (for the confusion of > and >> symbols)
    I am sure you meant
    Code:
    template <class T>
    Class1 < Class2 <T>>
    A problem that has now been fixed in the new c++11 standard. Any compiler that has been updated to conform will compile correctly.
    Quote Originally Posted by Falko-tux
    how can I typedef a template
    You can't, but you can use template aliasing which is also a c++11 feature. The only compiler I know of that supports this feature is gcc 4.7 and is still in earily development.
    0100 0111 0110 1111 0110 0100 0010 0000 0110 1001 0111 0011 0010 0000 0110 0110 0110 1111 0111 0010
    0110 0101 0111 0110 0110 0101 0111 0010 0010 0001 0010 0001 0000 0000 0000 0000
    0000 0000 0000 0000

  3. #3
    Join Date
    Aug 2008
    Posts
    902

    Re: Typedef a template

    Quote Originally Posted by Joeman View Post
    The only compiler I know of that supports this feature is gcc 4.7 and is still in earily development.
    Clang 3.0 also supports template aliases.

  4. #4
    Join Date
    Feb 2011
    Location
    Cosenza,Italy
    Posts
    62

    Re: Typedef a template

    ok, thank you!

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured