-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
src: simplify is_callable by making it a concept #58169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -111,7 +111,7 @@ struct CallLibuvFunction<ReqT, void(*)(ReqT*, Args...)> { | |||||
template <typename ReqT, typename T> | ||||||
struct MakeLibuvRequestCallback { | ||||||
static T For(ReqWrap<ReqT>* req_wrap, T v) { | ||||||
static_assert(!is_callable<T>::value, | ||||||
static_assert(!is_callable<T>, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return v; | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
template <typename T, void (*function)(T*)> | ||
struct FunctionDeleter { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.