use concepts instead of std::enable_if#16758
Merged
Merged
Conversation
elad335
requested changes
Feb 25, 2025
| 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>>(); |
Contributor
There was a problem hiding this comment.
This change is wrong, enable_if_t checks three things here:
- enable_bitcopy exists.
- enable_bitcopy is constexpr.
- enable_bitcopy::operator()() is true.
|
|
||
| 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); }; |
Contributor
There was a problem hiding this comment.
Suggested change
| 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)); }; |
Megamouse
reviewed
Feb 25, 2025
| { | ||
| return error.empty(); | ||
| } | ||
| operator bool() const |
Contributor
Author
There was a problem hiding this comment.
The indentation is correct now, it was using spaces before. Some lines in the file use spaces others tabs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was learning C++ concepts and decided to replace usages of
std::enable_ifandstd::void_twith concepts.