Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/req_wrap-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct CallLibuvFunction<ReqT, void(*)(ReqT*, Args...)> {
template <typename ReqT, typename T>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
template <typename ReqT, typename T>
template <typename ReqT, is_callable T>

struct MakeLibuvRequestCallback {
static T For(ReqWrap<ReqT>* req_wrap, T v) {
static_assert(!is_callable<T>::value,
static_assert(!is_callable<T>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can change type name T to is_callable T and remove this static_assertion.

"MakeLibuvRequestCallback missed a callback");
Comment on lines +114 to 115
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static_assert(!is_callable<T>,
"MakeLibuvRequestCallback missed a callback");

return v;
}
Expand Down
8 changes: 2 additions & 6 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,13 +689,9 @@ class NonCopyableMaybe {
};

// Test whether some value can be called with ().
template <typename T, typename = void>
struct is_callable : std::is_function<T> { };

template <typename T>
struct is_callable<T, typename std::enable_if<
std::is_same<decltype(void(&T::operator())), void>::value
>::type> : std::true_type { };
concept is_callable =
std::is_function<T>::value || requires { &T::operator(); };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For concepts like this, I'd prefer if we adopted a naming scheme like IsCallable


template <typename T, void (*function)(T*)>
struct FunctionDeleter {
Expand Down
Loading