Also, why is std::experimental::source_location loc = std::experimental::source_location::current(); loc.line better than __LINE__? what an unreadable monster that is!
Also, why is std::experimental::source_location loc = std::experimental::source_location::current(); loc.line better than __LINE__? what an unreadable monster that is!
- it has file name, line number, and char number! That already makes the number of characters more similar if that’s your metric
- it can be forwarded/passed around. It’s much harder to pass macros around
- it can easily capture the caller’s location rather than the location of the macro
#define __WHERE__ std::source_location::current()
:) auto loc = std::source_location::current();
at some point, which seems fair enough to me.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.
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.
D just uses __LINE__, because it hasn't got a preprocessor so the compiler can resolve the token properly.
The implementation of that is at https://github.com/dlang/dmd/blob/v2.094.2/src/dmd/expressio...
s/^/\/\// (and the reverse) work well for me. It nests.
you may use multiline string literals
(void) R"long-comment(
/* C-style comment */
std::cout << "hello" << std::endl;
)long-comment";