0

I have some class like :

 template<int DIMENSION, typename T> Vector { ... }  

Now, I want to specialize the typename and provide a new type using a typedef. I thus found an answer on StackOverflow at C++ typedef for partial templates

I thus did :

template < int DIMENSION> using VectorDouble= Vector<DIMENSION, double>;

This does not compile (error C2988: unrecognizable template declaration/definition). Is this because my compiler (Visual Studio 2008) doesn't allow it, or did I miss something ?

Thanks.

Community
  • 1
  • 1
nbonneel
  • 3,286
  • 4
  • 29
  • 39

2 Answers2

4

Template typedefs are supported in the next Standard- that is, basically, only the really, really, really new compilers support it. Even the newest VS doesn't support it becaue, well, it's not new enough, that's how new C++0x is.

In C++03, then typically, you use a struct.

template<int dimension> struct vector_double {
    typedef Vector<dimension, double> type;
};

Now it can be accessed like

int main() {
    vector_double<5>::type vec_double;
}
Puppy
  • 144,682
  • 38
  • 256
  • 465
2

The answer you refer to says:

If you have a C++0x/C++1x compiler

C++1x is not yet current, so most compilers don't support its features. In particular, VC++9.0 (VS2008) has almost no support for them. VC++10 (VS2010) does support some features, but I don't know if what you need is one of those.

Etienne de Martel
  • 34,692
  • 8
  • 91
  • 111