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
Show parent comment
9
u/matthieum Apr 19 '20
I have. I still remember with dread an API in a library I was using which had 3 booleans, all with a default value.
My personal stance is that no function should ever take a boolean as input, unless its very purpose is to internally set a boolean.
enum class X : std::uint8_t { No, Yes }is both verbose and silly looking, but:2, orvoid*or whatever.