我正在尝试生成template struct
#define REGISTER_FUNCTOR(type, func) \
template <OWNER> \
struct writeCharFunctor { \
void operator(PropInfoType::iterator& it, PdxWriterPtr pw)() { \
MemberProperty<OWNER,type> *ptr = (MemberProperty<OWNER, type> *)it->second; \
const char *propertName = ptr->m_propertyName.c_str(); \
if ( !ptr->m_getterFn ) { \
throw; \
} \
pw->###func(propertName,(pOwner->*(ptr->m_getterFn))()); \
} \
};
REGISTER_FUNCTOR(char,writeChar);
但我收到编译错误error C2061: syntax error : identifier 'OWNER'
我的函数名称对于每种类型都不同,因此不能直接使用模板参数(或者有办法执行此操作)
答案 0 :(得分:2)
应为template <class OWNER>
或template <typename OWNER>