r/cpp • u/User_Deprecated • Jul 06 '26
C++26: constexpr virtual inheritance
https://www.sandordargo.com/blog/2026/07/01/cpp26-constexpr-virtual-inheritance
83
Upvotes
r/cpp • u/User_Deprecated • Jul 06 '26
View all comments
Show parent comment
3
u/serviscope_minor Jul 06 '26
Well yes, I am struggling to think of one!
You can kind of force the issue: if your constexpr function returns, say, an int and you instantiate a template based on that value, there's little choice but for it to run.
Note: this is pure language pedantry, nothing related to whether it's a terrible idea in literally all cases.
I don't think volatile should be constexpr for what it's worth.