c++ - Internal error: el.c 1988
- Chris Smith (44/44) Sep 25 2005 /*
/* When trying to instantiate a template function that uses 1. a type parameter and 2. a non-type template parameter of the previously defined type, the compiler complains of an illegal type cast from "<type represented by T> to T". This error doesn't make any sense since T represents the type I'm converting from; T by itself isn't a real type. An attempt to specialize the function (#define SPECIALIZE) also results in Internal error: el.c 1988 Note that a class template with the same parameters works fine. I'm using DMC 8.45.6n I don't know if this is standard syntax, but MSVC 7.1 and GCC 3.4.4 don't have a problem with this (with or without SPECIALIZE). */ #define BUG #define SPECIALIZE #ifdef BUG template <class T, T Value> void f() { } #ifdef SPECIALIZE template <> void f<bool, true>() { } template <> void f<bool, false>() { } #endif //SPECIALIZE #endif //BUG template <class T, T Value> class myclass { public: T f() { return Value; } }; int main() { #ifdef BUG f<bool, true>(); #endif //BUG myclass<bool, true> myvar; //note that this works fine myvar.f(); }
Sep 25 2005