-
Notifications
You must be signed in to change notification settings - Fork 60
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
Require C++20 and update to C++20 #698
base: master
Are you sure you want to change the base?
Conversation
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.
I am generally very in favor of this. I am not yet entirely sure how to properly reflect this in the podio version. Strictly speaking it could be a breaking change, since we remove a "feature". I think we should at least put some warning / message into a podio tag to check if someone is still building podio with c++17 (and can't easily upgrade to c++20).
We potentially have to change a few of the LCG stacks that we use to have the necessary compiler (and ROOT) support.
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.
I think we potentially also have to have a discussion about some style rules around concepts, e.g. do we always use
template<typename T>
requires Concept<T>
or do we go to
template<Concept T>
where possible and only fall back to using requires
when necessary?
.github/workflows/ubuntu.yml
Outdated
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.
I suppose gcc11 doesn't yet have enough support for the features that we need?
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.
It's ROOT being built with C++17 and the check failing, I'm quite sure otherwise it would pass. I think Ubuntu24 will be there soon so maybe we can check in a few days.
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.
Ah right. In that case we could potentially add an ubuntu workflow based on a key4hep stack?
I have opened another PR (#700) with a warning when building with C++17 for a future tag.
I am against always using a Concept when possible. I think this should be something that can be reused in several places and I think for the ones created in this PR this is the case. Otherwise it becomes very hard to read if for every template you have to find out what the concept being used means. In the case when we have a reusable concept then I prefer the shorter one. |
Core guidelines advise to always constrain template with concepts I think the idea with using concepts everywhere is about using std concepts or building complex concepts with logic operators from them (not about introducing a separate, dedicated concept for every template argument). But I agree that introducing this policy here would be cumbersome |
|
||
Install ROOT 6.08.06 (or later) and set up your ROOT environment: | ||
Install ROOT 6.28.04 (or later) and set up your ROOT environment: |
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.
Install ROOT 6.28.04 (or later) and set up your ROOT environment: | |
Install ROOT 6.28.04 (or later) built with c++20 support and set up your ROOT environment: |
template <typename FromU> | ||
requires(Mutable&& std::is_same_v<detail::GetDefaultHandleType<FromU>, FromT>&& | ||
detail::isDefaultHandleType<FromU>) void setFrom(FromU value); |
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 formatting here should match the one in the source code
class RNTupleReader; | ||
class RNTupleWriter; | ||
} // namespace podio | ||
#endif | ||
|
||
namespace podio { | ||
|
||
#if !defined(__CLING__) | ||
// cling doesn't really deal well (i.e. at all in this case) with the forward | ||
// declaration here and errors out, breaking e.g. python bindings. | ||
class ROOTReader; | ||
#endif |
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.
I am not sure I understand why these can be removed.
#if PODIO_ENABLE_RNTUPLE | ||
friend RNTupleReader; | ||
friend RNTupleWriter; | ||
#endif | ||
|
||
#if !defined(__CLING__) | ||
friend ROOTReader; | ||
#endif | ||
|
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.
Same here, these changes if they are possible seem to be unrelated to the c++17 to c++20 changes (for me). If they are independent we should move them to another PR, I think.
template <typename DefT, template <typename...> typename Op, typename... Args> | ||
using detected_or = detail::detector<DefT, void, Op, Args...>; | ||
|
||
template <template <typename...> typename Op, typename... Args> | ||
using detected_t = typename detail::detector<nonesuch, void, Op, Args...>::type; |
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 is removed, because it's unused, I suppose?
template <typename FromU> | ||
requires(Mutable&& std::is_same_v<detail::GetMutableHandleType<FromT>, FromU>&& | ||
detail::isMutableHandleType<FromU>) void setFrom(FromU value) { |
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.
template <typename FromU> | |
requires(Mutable&& std::is_same_v<detail::GetMutableHandleType<FromT>, FromU>&& | |
detail::isMutableHandleType<FromU>) void setFrom(FromU value) { | |
template <typename FromU> | |
requires(Mutable && std::is_same_v<detail::GetMutableHandleType<FromT>, FromU> && | |
detail::isMutableHandleType<FromU>) | |
void setFrom(FromU value) { |
Does this formatting get past clang-format? I think this would be much more readable than the current form. Or do we have to update our .clang-format
?
So on a quick glance we are somewhat following this already and we could just quote this as a general (albeit a bit vague) guideline? |
Since the Key4hep stack and the LCG stack are both on C++20 for some time, we could start using C++20 features. This PR changes the requirements and uses in some places C++20 features.
BEGINRELEASENOTES
concept
andrequire
when possible. In some places like theUserDataCollection
andGenericParameters
it seems that cppyy (3.1.2 with ROOT 6.32.06) doesn't likerequires
norconcept
so they can't be changed for now.consteval
when possible which, unlikeconstexpr
, guarantees evaluation at compile-timestd::ranges::find
andstd::ranges::sort
ENDRELEASENOTES