mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
In a downstream project we are using the Swift code as a library and compiling with C++20. This mostly works except for two backward incompatibilities introduced by C++20: * [P1008] disallows aggregate initialization when defaulted or deleted constructors are specified. This lead to a compilation error for aggregate initialization of `swift::Compilation::Result`. The backward and forward compatible fix for that is to provide a constructor turning aggregate initializations into a normal constructor call. * [P1185] introduces more candidates for overload resolution of comparison operator calls. As explained in [P1630], this leads in some cases to ambiguity compilation errors in C++20, which is exactly the case with `swift::ValueOwnershipKind`. The fix in this case is to remove some redundant operator calls conditionally on the `__cpp_impl_three_way_comparison` feature test macro, which [includes the papers mentioned above][feature_test]. [P1008]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1008r1.pdf [P1185]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1185r2.html [P1630]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1630r1.html [feature_test]: https://en.cppreference.com/w/cpp/feature_test
56 KiB
56 KiB