cpp20 concepts - #3433
Open
tomc271 wants to merge 2 commits into
Open
Conversation
…h default value. `concept IsField = std::is_base_of_v<Field, T>`
Replaced template specializations with a single `if constexpr` block.
dschwoerer
reviewed
Aug 12, 2026
dschwoerer
left a comment
Contributor
There was a problem hiding this comment.
Looks good, just some minor cleanups would be nice.
| #include "bout/bout_types.hxx" | ||
|
|
||
| #include <string> | ||
| #include <type_traits> // Required for std::is_same_v |
Contributor
There was a problem hiding this comment.
I think the comment can go. clang-tidy will keep it up to date.
Suggested change
| #include <type_traits> // Required for std::is_same_v | |
| #include <type_traits> |
| ./src/sys/type_name.cxx | ||
| ./src/sys/utils.cxx | ||
| ./include/bout/git_metadata.hxx | ||
| ./src/sys/utils.cxx |
Contributor
There was a problem hiding this comment.
Has the formatting gone wrong here?
Suggested change
| ./src/sys/utils.cxx | |
| ./src/sys/utils.cxx |
ZedThree
requested changes
Aug 12, 2026
ZedThree
left a comment
Member
There was a problem hiding this comment.
A couple of little things to tidy up, otherwise looks great!
| // Overload 1: Three fields | ||
| template <typename T, typename U, typename V, | ||
| typename ResultType = std::common_type_t<T, U, V>> | ||
| requires IsField<T>&& IsField<U>&& IsField<V> |
Member
There was a problem hiding this comment.
@tomc271 Is there a reason we can't do:
Suggested change
| requires IsField<T>&& IsField<U>&& IsField<V> | |
| template <IsField T, IsField U, IsField V, | |
| typename ResultType = std::common_type_t<T, U, V>> |
Is it because T etc in this case are concepts, and common_type_t takes templates?
Comment on lines
+28
to
+31
| if constexpr (std::is_same_v<T, bool>) | ||
| return "bool"; | ||
| else if constexpr (std::is_same_v<T, int>) | ||
| return "int"; |
Member
There was a problem hiding this comment.
Could you run clang-tidy/clang-format over this? We should always have braces with if, and not have else following return
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.
No description provided.