rll::source_location struct

Provides information about the location of the current source file.

Class provides information about the location of the current source file. This class is a port of C++20 std::source_location. Example usage:

auto main() -> int {
  log::debug("I am called from {}, {}:{} in file {}!",
    rll::source_location::current().function_name(),
    rll::source_location::current().line(),
    rll::source_location::current().column(),
    rll::source_location::current().file_name()
  );
  fmt::println("I am called from {}", rll::source_location::current());
}

Output:

I am called from main, 5:7 in file main.c++!
I am called from main.c++:main 6:7

Public static functions

static auto current(char const* file = __builtin_FILE(), char const* function = __builtin_FUNCTION(), u32 line = __builtin_LINE(), u32 column = 0) →  source_location constexpr noexcept
Returns current source location.

Constructors, destructors, conversion operators

source_location() constexpr noexcept
Creates an invalid source_location.
source_location(char const* file, u32 const line, char const* function, u32 const column = 0) constexpr noexcept
Creates a source_location from given parameters.
~source_location() defaulted

Public functions

auto column() const →  u32 constexpr noexcept
Returns the column number. 0 if unknown or not available on compiler.
auto file_name() const →  std::string_view constexpr noexcept
Returns the file name.
auto function_name() const →  std::string_view constexpr noexcept
Returns the function name. NULL if unknown or not available on compiler.
auto line() const →  u32 constexpr noexcept
Returns the line number. 0 if unknown or not available on compiler.

Function documentation

rll::source_location::source_location(char const* file, u32 const line, char const* function, u32 const column = 0) constexpr noexcept

Creates a source_location from given parameters.

Parameters
file File name
line Number of the line in the file. 0 if NULL
function Function name
column Column number in the function. Defaults to 0