我有这个代码,我的期望是基于模板参数的类型会有两个不同版本的operator().
@H_404_2@#include <string>
#include <type_traits>
template<typename T>
struct Impl
{
std::enable_if_t<!std::is_pointer<T>::value,T> operator()(const std::string& key,int node)
{
return static_cast<T>();
}
std::enable_if_t<std::is_pointer<T>::value,int node)
{
return new T();
}
};
int main()
{
}
相反,我得到一个错误编译:
‘std :: enable_if_t< std :: is_pointer< _Tp> :: value,T> Impl< T> :: operator()(const string&,int)’不能用’std :: enable_if_t<(!std :: is_pointer< _Tp> :: value)重载,int)’