0
我写的模板整数包装类,我想基于模板参数类型的类提供一个分配新建分配FY操作:在模板类启用方法基于模板类型
template<typename IntType>
class secure_int {
public:
// enable only if boost::is_signed<IntType>
secure_int &operator=(intmax_t value) {
// check for truncation during assignment
}
// enable only if boost::is_unsigned<IntType>
secure_int &operator=(uintmax_t value) {
// check for truncation during assignment
}
};
因为运营商=不是成员模板,那么带有boost :: enable_if_c的SFINAE将不起作用。什么是提供这种功能的工作选项?
我这样去看它是否是一个工作解决方案,但我的公司还没有切换到C++ 11。 – kyku 2012-02-19 09:33:49