![]() |
Template Partial Specialization with a Template?
Here is my problem. I am using one of the implementations of TR1 that
has a hash_map template. for all the simple types hash_map<Key,Data> works because Code:
namespace stdIf you want to write your own key type, you can: Code:
struct MyKeyI have a template class thus: Code:
template<typename T>that will implicitly specialize any specialization of the generic TKey template. The inner code should be very simple: Code:
template<>kind of template mechanism that allows me to specify that this should be a generic template that can be specialized against a particular specialization of a TKey. |
Re: Template Partial Specialization with a Template?
My office mate and I found the answer last night...
so, given my key type: Code:
Code:
that it is legal to nest template definitions and partial specializations. That is what we are doing here; the outer 'template<>' is an indicator that we want to do a partial specialization of our 'struct hash'. The inner template<...> is a standard template definition, and the nesting of the two allows us to specify a templated definition of the partial specialization, as desired. |
| All times are GMT +5.5. The time now is 21:35. |