如何专门化所有枚举的模板。就像它一样boost::serialization
。
在提升:
template <typename Archive>
void serialize(Archive &AR, const unsigned int ver)
{
AR & enum__;
AR & int__;
AR & class__;
}
我需要operator&
所有枚举:
struct A
{
void operator&(int obj){std::cout << "1";}
void operator&(unsigned int obj){std::cout << "2";}
template <typename T>
typename std::enable_if<std::is_enum<T>::value,void>::type operator&(T & obj) { std::cout << "Is enum" << std::endl; }
template<typename T>
void operator&(T & obj){obj.metod(); std::cout << "3";} // this operator not for enums
};
enum enum__{AAA,BBB};
enum enum2__{AAA2,BBB2};
int main()
{
A a;
enum__ d = AAA;
a & d;
enum2__ e = AAA2;
a & e;
std::system("pause");
return 0;
}
错误 C2593:运算符 & 不明确