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
38
u/jbandela Apr 19 '20
C++20 designated initializers with NSDMI (combined with default arguments) allow for an elegant solution to print_squares
https://gcc.godbolt.org/z/-r6U3P
You have a single implementation. There is no question about what overload is getting called. There is a single point of reference for all the defaults (the definition of print_square_args).