|
Boost Users : |
From: Surya Kiran Gullapalli (skg_at_[hidden])
Date: 2005-10-27 02:41:37
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.
I've tried explicit template instantiation, (by passing a flag to my
compiler), but in that case, i've to do that for every class
suppose i try to invoke
std::vector <someOtherClass> someVector;
I've to instantiate this also explicitly. (which is a problem for me,
because, I use a lot of standard library, and its a pain for me to
instantiate every time.
Also, if i do the above, i can always instantiate myClass also like this.
template class myClass <someOtherClass> ;
and which i want to avoid this..
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)
Thanks,
Surya
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net