C++ Insights - Episode 38: User-provided vs. user-declared

Поділитися
Вставка
  • Опубліковано 18 гру 2024

КОМЕНТАРІ • 4

  • @ggladilov
    @ggladilov 11 місяців тому +1

    Is it the same with -O3? What does destructing an empty object mean? Would empty struct optimisation interfere here?

    • @andreas_fertig
      @andreas_fertig  11 місяців тому

      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.

  • @theintjengineer
    @theintjengineer Рік тому

    Thanks for going through that. Keep it up!
    Grüße aus'm Wald.

  • @YourCRTube
    @YourCRTube Рік тому

    Good example, esp. with the chain effect with optional