I
itaj sherman
Simple testing suggests I can achieve the same end with less work and
using an arguably clearer approach via enable_if. Overloading my
forwarding template as follows works for me with VC10 and gcc 4.5 (on
simple tests):
template<typename T>
typename std::enable_if<
!std::is_pointer<
fwd(T&& param)
{
std::cout << "General forwarding template => ";
f(std::forward<T>(param));
}
template<typename T>
typename std::enable_if<
std::is_pointer<
fwd(T&& param)
{
std::cout << "Pointer forwarding template => ";
f(std::forward<T>(param));
}
Am I overlooking a drawback to this technique?
I think this is what others meant too, but in my words: the resolution
feature of c++ (both in functions and template class specializations)
applies a very useful partial order on the specializations (per type
hierarchies and the specializations of the template's parameters).
This scheme only works for exact partitions (equivalence relation
rather than a partial order). This is why in my other post I was
trying to "abuse" the template class specialization feature in order
to achieve a workaround.
itaj