Re: partial specialization
"Jack Hanebach" <firstname@lastname.net> wrote in message
news:u53ZcVOlIHA.4712@TK2MSFTNGP04.phx.gbl
Given:
template<typename T1, typename T2>
struct A
{
void foo() {}
};
Yet, according to VC8 and comeau, we cannot partially
specialize A::foo() like that:
template<typename T>
void A<T, double>::foo() {}
There ain't no such thing as partial specialization of function
templates. You can simulate it by delegating to a class template, which
in turn can be partially specialized:
template <typename T1, typename T2>
struct FooImpl {
static void foo(A* pThis) {};
};
template<typename T1, typename T2>
struct A
{
void foo() { FooImpl<T1, T2>::foo(this); }
};
// Partial specialization
template<typename T>
struct FooImpl<T, double>
{
static void foo(A* pThis) {}
};
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925