typedef auf partieller Templateklasse



  • Hallo zusammen.

    Ich stehe vor dem Problem, dass ich gerne einer partiell spezialisierten Templateklasse ein typedef verpassen möchte. Leider weiß ich nicht, wie...

    Idee, die leider nicht funktioniert:

    typedef std::map<int, T> IntMapping<T>;
    typedef std::map<T, int> IntValueMap<T>;
    

    Leider kompiliert weder das eine noch das andere. Ich hoffe, dass der Code ausreichend ist, um auszudrücken, was ich gerne möchte. Vielleicht weiß jemand Rat.



  • template typedefs gibts leider in C++98 nicht - später schon. Workaround:

    template <class T>
    struct IntValueMap
    {
      typedef std::map<T, int> type;
    };
    
    //...
    
    IntValueMap<std::string>::type stringintmap;
    

Anmelden zum Antworten