The example is too simple for the compiler with -O3. Still, in a code base that does something with the optional, it depends on the compiler's ability to see through it. In the worst case, the compiler performs a call to an empty destructor. That might not cost much, but the costs increase if it affects caching because the destructor is not in the hot cache.
Is it the same with -O3? What does destructing an empty object mean? Would empty struct optimisation interfere here?
The example is too simple for the compiler with -O3. Still, in a code base that does something with the optional, it depends on the compiler's ability to see through it. In the worst case, the compiler performs a call to an empty destructor. That might not cost much, but the costs increase if it affects caching because the destructor is not in the hot cache.
Thanks for going through that. Keep it up!
Grüße aus'm Wald.
Good example, esp. with the chain effect with optional