此代码始终打印 0,我不明白为什么。我错过了什么吗?
#include<iostream>
#include<type_traits>
template <class T, typename = void>
struct has_default_operator: std::false_type {};
template <typename T>
struct has_default_operator<T, std::void_t<decltype(std::declval<T>()())>> : std::true_type {};
class Entity{
public:
Entity() = default;
};
int main(){
std::cout<< has_default_operator<Entity>::value;
}
当有默认操作符时,代码应该打印 1