Hacker News new | ask | show | jobs
by MauranKilom 2021 days ago
Presumably it would become

  auto loc = std::source_location::current();
at some point, which seems fair enough to me.
2 comments

I mean, don't love the macros - but that still looks like a load of typing to me - and it even reads less well than __LINE__ if you are looking at from a literate programming perspective.

It's tidier for the compiler though, but the change does not seem to make it easier for the reader of the code to comprehend.

It is since C++20. Comment author tries to make code verbose to make their point or does not know about auto and the state of C++.
I simply copied it from the article (minus the surrounding function).

Fortunately you only need to write this at the utility function, not at every call site, so it's ok.

In general I find various new features in C++ suffer from verbosity, but of course without experimental this one gets better.

auto in function signatures is just really, really stupid.