Thread: Alias for class template

  1. #1

    Join Date
    Apr 2008

    Alias for class template

    Unfortunately, it's illegal to make a typedef for an incomplete type, like:
    typedef std::vector MyVector; // Illegal!
    Is there any kind of workaround for this without having to use macros?

  2. #2
    The larch
    Join Date
    May 2006
    I think this might become possible in C++0x.

    But in this particular example, why would it be useful?
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3

    Join Date
    Apr 2008
    I have a class template with two parameters, the second of which is a template template parameter:
    template <typename T, template <typename> class T2>
    class Object
        friend class Object <T, ?>;
    The second template parameter can only be one of two types, and I want any class Object <T, FirstPossibleType> to be friends with the class Object <T, SecondPossibleType> and vice versa.

    Template metaprogramming would normally allow this to be possible, except the second parameter is a template template parameter and cannot be typedef'd. (None of this would be an issue if friend class declarations could be templated...)
    Last edited by rudyman; 07-26-2008 at 05:12 PM. Reason: Typo

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Specialising a member function with a template template parameter
    By the4thamigo_uk in forum C++ Programming
    Replies: 10
    Last Post: 10-12-2007, 04:37 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  4. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 12:54 PM