I have is_callable
trait as below:
template<class T, class = void>
struct is_callable: std::false_type {};
template<class T>
struct is_callable<T, std::void_t<decltype(&T::operator())>>: std::true_type {}; // (A)
There I have to wrap decltype(&T::operator())
with std::void_t
rather than use just the decltype
itself like this:
template<class T>
struct is_callable<T, decltype(&T::operator())>: std::true_type {}; // (B)
If I use just the decltype
itself (B) then I got no compilation error thus I assume that decltype
is still in SFINAE context but the detection does not work - the trait value is always false. Can someone explain how exactly void_t
helps here.