Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
source_location: A Backport of std::source_location

The source_location sub-package provides a facility akin to that provided by the C++20 std::source_location class.

The public header is

The Bazel target is

//:source_location

Source Locations

arene::base::src_line_info stores information about a line of code: the name of the source file where it is located, the name of the function where it is located, and the line number. This is similar to std::source_location, except that no column number is provided, as it is not available without the compiler intrinsics used for std::source_location.

The main use case is in association with the ARENE_GET_SRC_CODE_LOCATION_INFO macro, which captures the information about the source file where the macro is used:

void foo(const arene::base::src_line_info& info);
void bar() {
}
#define ARENE_GET_SRC_CODE_LOCATION_INFO()
Definition src_line_info.hpp:45
Container for the location information associated with a line of source code.
Definition src_line_info.hpp:20

Sadly, this cannot meaningfully be used as a default argument in a function definition (like std::source_location::current()), since it would yield the location of the function definition, and not the location of the function call.