-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
use concepts instead of std::enable_if #16758
Conversation
@@ -18,9 +18,8 @@ namespace utils | |||
}; | |||
|
|||
template <typename T> | |||
concept Bitcopy = (std::is_arithmetic_v<T>) || (std::is_enum_v<T>) || Integral<T> || requires () | |||
{ | |||
std::enable_if_t<std::conjunction_v<typename T::enable_bitcopy>>(); |
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.
This change is wrong, enable_if_t checks three things here:
- enable_bitcopy exists.
- enable_bitcopy is constexpr.
- enable_bitcopy::operator()() is true.
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.
fixed
rpcs3/util/serialization.hpp
Outdated
@@ -30,7 +29,7 @@ namespace utils | |||
}; | |||
|
|||
template <typename T> | |||
concept ListAlike = requires (std::remove_cvref_t<T>& obj) { obj.insert(obj.end(), std::declval<typename T::value_type>()); }; | |||
concept ListAlike = requires(std::remove_cvref_t<T>& obj, T::value_type item) { obj.insert(obj.end(), item); }; |
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.
concept ListAlike = requires(std::remove_cvref_t<T>& obj, T::value_type item) { obj.insert(obj.end(), item); }; | |
concept ListAlike = requires(std::remove_cvref_t<T>& obj, T::value_type item) { obj.insert(obj.end(), std::move(item)); }; |
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.
also fixed
{ | ||
return error.empty(); | ||
} | ||
operator bool() const |
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.
Indentation
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.
The indentation is correct now, it was using spaces before. Some lines in the file use spaces others tabs.
I was learning C++ concepts and decided to replace usages of
std::enable_if
andstd::void_t
with concepts.