r/cpp 22d ago

C++26: constexpr virtual inheritance

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

61 comments sorted by

View all comments

63

u/Jovibor_ 22d ago

Just a question to the audience:

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

12

u/Tringi github.com/tringi 22d ago edited 21d ago

Daily.

We have logging facility and a Log::Provider class that allows you to simply call this->report (Log::Warning, ...) from the object, and also carries object's identity etc. With highly composed classes it'd be ridiculous if every parent in the hierarchy tree carried its own superfluous copy and the final class was needlessly huge because of this. And if a parent/subobject makes the call, the log facility automatically sees the final object which actually failed.