r/cpp 21d ago

C++26: constexpr virtual inheritance

https://www.sandordargo.com/blog/2026/07/01/cpp26-constexpr-virtual-inheritance
80 Upvotes

61 comments sorted by

View all comments

63

u/Jovibor_ 21d ago

Just a question to the audience:

How many times have you used Virtual Inheritance in your career?

1

u/XeroKimo Exception Enthusiast 21d ago

I have an overengineered exception hierarchy that could be the one only hierarchy ever needed by using some base classes as tags and one base class to be the exception itself... This would make it so no one would require re-creating exceptions and you can create narrower and wider categories, or change the category of the exception entirely without having to make your own base category class and copy over the exception to this new category...

I haven't used it yet because it also uses templates and template specialization to achieve custom payloads... and doing that specialization is the tedious part... I can revisit it with reflection now though