Fix std::set for InvalidatableFile in C++20 - #1941
Conversation
Codex suggestion
std::set for InvalidatableFile in C++20
|
@dpgrote does the change I pushed work for you, too? |
Yes, this works, WarpX compiles successfully. |
franzpoeschel
left a comment
There was a problem hiding this comment.
I am a bit surprised why your build system decided to compile openPMD-api with the C++20 standard. This missing definition should not matter for inclusion in a C++20 project; the openPMD-api itself can still be compiled with C++17.
Fixing this is simple enough though and we will move to C++20 at some point anyway, so we should go ahead with fixing this. The current state of the PR has two little issues. I will later push a commit with a fix, could you give it another test again then?
Our CMake logic says in openPMD-api that we use C++17 or newer. So openPMd-api itself can be built with newer standards if the compiler supports it. Additionally, if a downstream project used a newer C++ std then our public headers naturally will be parsed as such, too. |
|
|
||
| bool openPMD::InvalidatableFile::operator<(InvalidatableFile const &f) const | ||
| { | ||
| return operator*() < *f; |
There was a problem hiding this comment.
Looking at InvalidatableFile::operator*() this sorts by name. ok!
There was a problem hiding this comment.
Yup, this does the same. I just wanted to avoid having two distinct implementations.
This is needed by AppleClang 21.0.0 to avoid the compiler error shown below. Since
InvalidatableFileis used in astd::set, the compiler now requires the comparison operators to be defined for it.The C++20 standard way of doing this is the spaceship operator,Needs a comparison operator. With the change in this PR, the compilation (of WarpX) is successful.<=>.