I\'m asking for a template trick to detect if a class has a specific member function of a given signature.
The problem is similar to the one cited here http://www.go
With c++ 20 this becomes much simpler. Say we want to test if a class T has a member function void T::resize(typename T::size_type). For example, std::vector has such a member function. Then,
template
concept has_resize_member_func = requires {
typename T::size_type;
{ std::declval().resize(std::declval()) } -> std::same_as;
};
and the usage is
static_assert(has_resize_member_func, "");
static_assert(has_resize_member_func == false, "");