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
2
u/qoning Apr 19 '20
This is what I ended up doing in my logger that uses std::source_location.
Works for pretty much every use case I had.
If you excuse the reddit width, basically hijacking the first string_view (or string or const char* or whatever) parameter to implicitly construct loc_obj_t.
Sure, it means that you need to know the type of the first argument, which is the only downside for me.