source-location::current()

We can print the filename, the line, and the function name as we did with macros before.

#include <iostream>
#include <source_location>

int main() {
    const auto &source = std::source_location::current();
    std::cout << source.file_name() << ":"
              << source.line() << ":"
              << source.function_name() << "\n";
}
example.cpp:5:int main()