That's not exactly true, see here or here.
First source is 5 years old, second – 8.
I agree with eXpl0it3r regarding that careful design can usually avoid DoD relationships.
Yep, I agree. It's actually first situation since years when I realised I have fallen into diamond problem and I want to keep it that way.
However, considering
DoD definition, virtual inheritance can make this situation non-ambigous and that means, using
virtual keyword solves my problem. It's not DoD anymore.
Also, "detectable overhead" is very vague. Of course you won't see your game run at half the framerate because of virtual inheritance. But as SFML is a library that has thousands of different application scenarios, such analysis has to be taken very carefully, on multiple compilers, otherwise it's worthless. Your benchmark may not be representative because it uses a single translation unit, where the compiler can perform a lot of optimizations (static binding) because it sees all the involved classes. This may be different if this is offloaded to the linker, or even at runtime through dynamic libraries.
You have a point. I tested it now with multiple translation units and dynamic linking – there's still no difference in execution time. Oh, well there is. ~0.1 second per 2000000000 calls with multiple translations units and ~0.1 second per 142857143 calls with dynamic linking, both are less than 1ns per call (same code but adjusted to multiple translation units and dynamic linking). Also keep in mind that my tests involve things that won't happen while using sf::Drawable (like member varialbe)
Yet you're right that it may be this good only in GCC, I'll test it on
clang and MSVC later.
//edit: Okay, tested on clang 3.8.
Static linking: virtual inheritance is 0.14s per 4e9 calls faster than traditionall one.
Dynamic linking: Normal is 0.71s per 4e9 calls faster.
So, as you can see differences are way below standard error and I can't really measure anything worth being considered.
sf::Text is a class to visualize text graphically and nothing more. Your FpsMeter however adds logic to it. Its purpose is to display the FPS; how this is done (by sf::Text) is an implementation detail. Many of the sf::Text methods may not be meaningful for your case, see LSP.
All methods existing in
sf::Text are useful in
FpsMeter, even
sf::Text::setString. Oh, and I didn't break LSP,
FpsMeter can be used everywhere where
sf::Text is being used.
Yes, but multiple inheritance and Diamond-of-Death-relation are not equivalent.
Multiple inheritance is most popular cause of DoD and as I stated a 'few' lines above, It's not DoD if
virtual keyword is used (properly ofc).