Skip to content

Source Location

1
#include <source_location>

1
2
3
4
5
6
void 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';
}

1
print_msg_with_line("Hello world!");

Share Snippets