我想专门声明一个模板函数:
template<typename Type> Type read(std::istream& is);
然后我有很多静态实现
static int read_integer(std::istream& is);
aso 现在我想做一个宏,以便读取的专业化非常简单:
SPECIALIZE_READ(read_integer)
所以我想我会采用 boost::function_traits 的方式并将 SPECIALIZE_READ 声明为:
#define SPECIALIZE_READ(read_function) \
template<> boost::function_traits<read_function>::result_type read(std::istream& is) { \
return read_function(is); \
}
但 VC++ (2008) 编译器抱怨:'boost::function_traits':'read_integer' 不是参数'Function' 的有效模板类型参数
想法?