Details
-
Epic
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
None
-
None
-
C++20 constexpr @ Qt
Description
C++20 added futher relaxations for constexpr functions:
- virtual function calls
- dynamic_cast and polymorphic typeid
- try-catch blocks
- asm, unless "executed" (__cpp_constexpr >= 201907L)
- T t; (default initialisation) (__cpp_constexpr >= 201907L)
- changing the active member of a union (__cpp_constexpr >= 202002L)
- memory allocation and deallocation ("constexpr std::string and std::vector") (defined(__cpp_constexpr_dynamic_alloc))
As these are all not backwards-compatible with C++17, so all we can realistically do is try and make some interesting functions or classes C++20 constexpr, much like we did in C++11 and C++14 (Q_RELAXED_CONSTEXPR).
For that, we might want to add a Q_CPP20_CONSTEXPR, though the extensions enumerated above have been merged into the IS in different meetings, so the __cpp_constexpr macro has several potential values on it's way to full C++20 conformance, so one macro may not be sufficient, or we need to use __cpp_constexpr manually (at least we wouldn't need to check for it to be defined anymore, one might hope, simplifying the condition to #if __cpp_constexpr >= 201907L).
Attachments
Issue Links
- is required for
-
QTBUG-99243 Initiative: Qt and C++20
- Open
-
QTBUG-109361 C++20 is required for the development and building of Qt itself (Phase II)
- Open