In following code, could anyone explain why do I get following error:
"error: no type named ‘type’ in struct std::enable_if<false, double>
According to my understanding of enable_if_t, there should not be any problem at compile time if I am not using function p. It should simply not get generated for simple types.
But when I change condition to !is_class_v<T>
, it works fine for simple types but then it stops working for class types.
template<typename T>
class Smart_class
{
public:
enable_if_t<is_class_v<T>, T> p(T t)
{
};
};
void f()
{
Smart_class<double> a;
}