Skip to content

cpp20 concepts - #3433

Open
tomc271 wants to merge 7 commits into
boutproject:nextfrom
tomc271:cpp20-concepts
Open

cpp20 concepts#3433
tomc271 wants to merge 7 commits into
boutproject:nextfrom
tomc271:cpp20-concepts

Conversation

@tomc271

@tomc271 tomc271 commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

…h default value.

`concept IsField = std::is_base_of_v<Field, T>`
Replaced template specializations with a single `if constexpr` block.

@dschwoerer dschwoerer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, just some minor cleanups would be nice.

Comment thread include/bout/sys/type_name.hxx Outdated
Comment thread CMakeLists.txt Outdated

@ZedThree ZedThree left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A couple of little things to tidy up, otherwise looks great!

Comment thread include/bout/where.hxx Outdated
// 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>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@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 thread include/bout/sys/type_name.hxx Outdated
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";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you run clang-tidy/clang-format over this? We should always have braces with if, and not have else following return

@ZedThree

Copy link
Copy Markdown
Member

You might need to bump Standard: c++20 in .clang-format btw, otherwise you'll get some weird formatting, I've just discovered!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants