C++ class template specialization for given template class -
i try implement template class , want restrict specialized given template class. example, in following codes, want define template class ctest
specialized std::vector<t>
template parameter t
. other template parameters, class should undefined. how implement template class?
// interface should following //template <typename std::vector<t> > //class ctest<std::vector<t> >; int main(int argc, char* argv[]) { ctest<std::vector<int> > t1; // successful ctest<std::vector<string> > t1; // successful ctest<int> t2; // compile error return 0; }
leave primary template undefined , partially-specialize types want admit:
template <typename> class ctest; // undefined #include <vector> template <typename t, typename alloc> class ctest<std::vector<t, alloc>> { // ... template here ... };
Comments
Post a Comment