src: simplify is_callable by making it a concept · nodejs/node@69b5607

Original file line numberDiff line numberDiff line change

@@ -661,13 +661,9 @@ struct MallocedBuffer {

661661

};

662662
663663

// Test whether some value can be called with ().

664-

template <typename T, typename = void>

665-

struct is_callable : std::is_function<T> { };

666-
667664

template <typename T>

668-

struct is_callable<T, typename std::enable_if<

669-

std::is_same<decltype(void(&T::operator())), void>::value

670-

>::type> : std::true_type { };

665+

concept is_callable =

666+

std::is_function<T>::value || requires { &T::operator(); };

671667
672668

template <typename T, void (*function)(T*)>

673669

struct FunctionDeleter {