-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
DeviceEvent shouldn't use C++20 initializers #34169
Comments
@mwswartwout @andy31415 Please take a look? I did not realize that syntax was not valid c++17 when reviewing #32935 ... |
I also didn't know that designated initializers were C++20, I thought they were C++17. Doing some googling it seems that most (all?) major compilers have added early support for them in C++17, and don't complain unless @ksperling-apple did you encounter a build environment that failed to compile with these? If we do remove these I think we should add something to CI that will break if they're added again in the future. I'm not sure the feasibility of enabling |
We do compile with I don't recall running into any build errors over these specific initializers, but I think in general I don't think they make great API due to the restrictive way they can be used in C++ (compared to C), like initialization order having to match declaration order without skipping any fields. This means reordering members or adding members anywhere other than at the end suddenly becomes a source-breaking change. A constructor (or a static factory method in case of something like |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Remove stale label or comment or this will be closed in 30 days. |
#32935 introduced C++20 aggregate initializer syntax for
DeviceEvent
objects in various places. That's not ideal in a C++17 code base and doesn't match the code style used everywhere else.Can we define constexpr factory functions for each event type instead that set the
type
and the relevant part of the union?The text was updated successfully, but these errors were encountered: