r/cpp • u/anonymous23874 • 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
r/cpp • u/anonymous23874 • Apr 19 '20
View all comments
7
u/kritzikratzi Apr 19 '20 edited Apr 19 '20
i disagree a bit. when used sparingly, default arguments are still handy here and there.
for me the main conclusion missing from the article is that c-style struct initializers would be a good enough replacement for named parameters. e.g.
doTask({.task=task1,.captureStdout=true});edit: just found out we got half-baked designated initializers in c++20. could be better, but i'll happily take it :)