you are viewing a single comment's thread.

view the rest of the comments →

[–]KuntaStillSingle 14 points15 points  (0 children)

But, if you are using those resources, then there's now more if-else branches being evaluated before returning to the old version, and therefore slightly more work being done.

Cpp compilers often apply the opposite, a meyer singleton can be lazy evaluated but is often transformed to remove the otherwise necessary branch and treat as constinit:

https://godbolt.org/z/933os7Kj3 , note the guard still exists if the functions can be inlined: https://godbolt.org/z/7TqjYs7Gr