Is it possible to specialize one function of a template (which accepts multiple parameters) based on one parameter only?
For example:
I declare a template class:
which has one function:Code:template<typename K, typename D> class RBTree{ . . . };
and I try to specialize it for the first parameter:Code:template <typename K, typename D> bool RBTree<K,D>::LessThan(const K t1, const K t2){ return t1 < t2; }
but this fails with a compile error. Is what I want even possible? The only C++ text I have in front of me is pathetic at templates, and I can't find anything online that's doing this -- it's easy enough to specialize on ALL parameters; I only want to specialize on one parameter, and I only want to specialize two out of twenty-odd functions.Code:template <typename D> bool RBTree<char *, D>::LessThan(const char* t1,const char* t2){ return strcmp(t1,t2) < 0; }



LinkBack URL
About LinkBacks


