"Suki"
Hi, I'm writing a templated class, and i dont want to use the class otherthan for some predetermined types, say, int, double etc.
This class has no meaning for typenames other than those few.
========================= template <class T> myClass {....} ;
myClass<int> intClass ; myClass<float> floatClass ; myClass<char> charClass ; =========================
The compiler should not complain for the first 2 instantiations, but should bail out at the 3rd instantiation (charClass). Is there any way i can achieve this, using standard c++ or boost.
Declarative way:
template <class T>
struct myClass_impl
{
...
};
template <class T>
struct myClass;
template<>
myClass<int> : myClass_impl<int>
{};
template<>
myClass<float> : myClass_impl<float>
{};
template<>
myClass<char> : myClass_impl<char>
{};
Imperative way:
#include
to summarize my question, is there any way i can restrict the compiler to accept only few type names for my templated class (i.e., using standard c++ or boost)
HTH, -- Dave Abrahams Boost Consulting www.boost-consulting.com