0
我想產生一個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'
我的函數名是對每種類型不同的多種定義,所以不能直接使用模板參數(或有辦法做到這一點)