Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 7
    Ok, the OP made the error of giving their question a misleading title. But when we put this aside for a moment, I don't see how this this answers the actual question (which is how to avoid an overly complicated approach for the described problem)? Commented Dec 19, 2020 at 13:39
  • 1
    You're right about zero overhead meaning features don't cost if you don't use them. And its a darn good thing too! Because otherwise, if features also didn't cost if you did use them how would I ever get paid well for writing good clean efficient software! All C++ programs would run in zero time no matter how badly written! Commented Dec 19, 2020 at 15:52
  • 22
    The zero-overhead principle is two-pronged: the first part is ‘you don’t pay for what you don’t use’ as you say, but the other is ‘if you do use it, you couldn’t have done it better by hand’ (this is how Herb Sutter uses the term for example, so it’s not just my personal opinion). The asker is clearly referring to the second part. Commented Dec 19, 2020 at 21:06
  • 1
    Also, the talk I linked points out how exceptions are actually in violation of the zero-overhead principle, both parts of it. Commented Dec 20, 2020 at 9:12
  • 1
    @gnasher729: what makes you think the OP knew already, for example, what James McLeod suggested? Commented Dec 20, 2020 at 10:53