r/cpp • • Apr 19 '20

Default function arguments are the devil

https://quuxplusone.github.io/blog/2020/04/18/default-function-arguments-are-the-devil/
90 Upvotes

149 comments sorted by

View all comments

Show parent comment

1

u/khleedril Apr 19 '20

Didn't you just contradict yourself? You ended up agreeing with the guidelines.

-2

u/cat_vs_spider Apr 19 '20 edited Apr 19 '20

I'll admit I haven't studied the core guidelines in detail on this particular issue. But the guidelines here advocate for using a default parameter if possible rather than an overload, and I disagree because (if nothing else), an overload is strictly more flexible because you can reorder the arguments.

I don't see how I ended up agreeing with the core guidelines here. There's no guarantee that void doComplicatedAction(bool withFizzBozzer = true) implements the same semantics for true and false either. In my experience, it usually doesn't.

Edit: syntax error