you need to specialize the class template
Quote:
Quote:
template<typename T>
struct S<T*>
{
static unsigned int f(T * const & t_)
{
your code for void *
}
};
it works now :) omitted the specialization for void*, and provided
implementation for f(T* const&). this way all the pointer types will
have a separate function, which means code duplication. in this very
case it's not a problem, since the body of the fn is rather simple and
will be inlined anyway, but for other cases i still wonder how could
one instruct the compiler to use the void* implementation.
my solution:
template<>
inline S<void*>::f(void* const& t_)
{
return calculated hash by casting t_ to int and shifing
}
template<T>
inline S<T*>::f(T* const& t_)
{
return S<void*>::f(t_);
}
this approach would still work when the functions are more complex, but
the same for all pointer types. in that case, the general f()
implementation should be inlined, while the specialized void* not, to
avoid code bloat.
thanks for the replies.
cheers, p