8 May
2002
8 May
'02
2:06 a.m.
The following works as desired in CBuilder C++ 6.0: As you have discovered, Borland has a hard time with compile-time constants used in template parameters. #include <typeinfo> #include <iostream> #include "boost/config.hpp" template <class T> struct traita { BOOST_STATIC_CONSTANT(int, value=0); }; template <> struct traita<int> { BOOST_STATIC_CONSTANT(int, value=1); }; template <class T, int> struct trait1 {}; template <class T> struct trait { BOOST_STATIC_CONSTANT(int, value=traita<T>::value); typedef trait1<T, (traita<T>::value)> t1; }; int main(int argc, char* argv[]) { std::cout << typeid(trait<int>::t1).name() << std::endl << trait<int>::value << std::endl ; return 0; }