Specializing Perfect Forwarding Templates?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top