C++26 accepts proposal P3533R2, which removes the long-standing prohibition on using constexpr with virtual inheritance. Previously, constructors and destructors of types with virtual bases could not be constexpr, and Clang rejected all member functions of such types. With this change, objects with virtual bases can be constructed at compile time. The practical impact is significant: std::ios_base uses virtual inheritance, so this unblocks constexpr-ification of the entire iostream hierarchy and related library facilities like chrono exception types. The proposal also eliminates the concept of 'constexpr-suitable' functions, moving C++ toward a model where constexpr is a simple opt-in with only evaluation-time restrictions rather than syntactical ones. The only remaining syntactical restriction is coroutines, which P3367 targets for C++29.

5m read timeFrom sandordargo.com
Post cover image
Table of contents
A quick recap on virtual inheritanceWhat the proposal changesWhy this mattersConclusionConnect deeper
2.5K Impressions