The following code, which attempts to specialize the template for the "special" class, based on the returned type type of member function pointer types, results in a compilation error with VC9:
template<class F> struct special {}; template<class C> struct special<void(C::*)()> {}; template<class R, class C> struct special<R(C::*)()> {}; struct s {}; int main() { special<void(s::*)()> instance; return 0; }
error C2752: 'special': more than one partial specialization corresponds to a list of template arguments
The same code is accepted by GCC-4.3.4, as shown in the image: http://ideone.com/ekWGg
Is this an error in VC9, and if so, is this error stored in VC10?
However, I came up with a terrifying obsessive workaround (at least for this particular use case).
#include <boost/function_types/result_type.hpp> #include <boost/type_traits/is_same.hpp> template<typename F, typename R> struct is_result_same : boost::is_same< typename boost::function_types::result_type<F>::type, R > {}; template<class F, bool = is_result_same<F, void>::value> struct special {}; template<class R, class C> struct special<R(C::*)(), true> {}; template<class R, class C> struct special<R(C::*)(), false> {};
c ++ visual-c ++ templates member-function-pointers partial-specialization
Functastic
source share