Source Location Headers 1#include <source_location> Function that requires source location 1 2 3 4 5 6void print_msg_with_line( std::string_view message, const std::source_location &location = std::source_location::current()) { std::cout << "info: " << location.file_name() << ':' << location.line() << ' ' << message << '\n'; } Call function with source location 1print_msg_with_line("Hello world!"); Share Snippets