3#if defined(ERRORS_USE_STD_SOURCE_LOCATION)
4#include <source_location>
9#if defined(__clang__) && !defined(__apple_build_version__) && \
10 (__clang_major__ >= 9)
11#define ERRORS_SOURCE_LOCATION_HAS_BUILTIN_FILE
12#define ERRORS_SOURCE_LOCATION_HAS_BUILTIN_FUNCTION
13#define ERRORS_SOURCE_LOCATION_HAS_BUILTIN_LINE
14#define ERRORS_SOURCE_LOCATION_HAS_BUILTIN_COLUMN
15#elif defined(__apple_build_version__) && defined(__clang__) && \
16 (__clang_major__ * 10000 + __clang_minor__ * 100 + \
17 __clang_patchlevel__ % 100) >= 110003
18#define ERRORS_SOURCE_LOCATION_HAS_BUILTIN_FILE
19#define ERRORS_SOURCE_LOCATION_HAS_BUILTIN_FUNCTION
20#define ERRORS_SOURCE_LOCATION_HAS_BUILTIN_LINE
21#define ERRORS_SOURCE_LOCATION_HAS_BUILTIN_COLUMN
23#elif defined(__GNUC__) && \
24 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
25#define ERRORS_SOURCE_LOCATION_HAS_BUILTIN_FILE
26#define ERRORS_SOURCE_LOCATION_HAS_BUILTIN_FUNCTION
27#define ERRORS_SOURCE_LOCATION_HAS_BUILTIN_LINE
28#define ERRORS_SOURCE_LOCATION_NO_BUILTIN_COLUMN
30#elif defined(_MSC_VER) && !defined(__clang__) && \
31 !defined(__INTEL_COMPILER) && (_MSC_VER >= 1926)
32#define ERRORS_SOURCE_LOCATION_HAS_BUILTIN_FILE
33#define ERRORS_SOURCE_LOCATION_HAS_BUILTIN_FUNCTION
34#define ERRORS_SOURCE_LOCATION_HAS_BUILTIN_LINE
35#define ERRORS_SOURCE_LOCATION_HAS_BUILTIN_COLUMN
43#if defined(ERRORS_USE_STD_SOURCE_LOCATION)
44using source_location = std::source_location;
50#if defined(ERRORS_SOURCE_LOCATION_HAS_BUILTIN_FILE) && \
51 defined(ERRORS_SOURCE_LOCATION_HAS_BUILTIN_FUNCTION) && \
52 defined(ERRORS_SOURCE_LOCATION_HAS_BUILTIN_LINE) && \
53 defined(ERRORS_SOURCE_LOCATION_HAS_BUILTIN_COLUMN)
55 current(
const char *fileName = __builtin_FILE(),
56 const char *functionName = __builtin_FUNCTION(),
57 const uint_least32_t lineNumber = __builtin_LINE(),
58 const uint_least32_t columnOffset = __builtin_COLUMN())
noexcept
59#elif defined(ERRORS_SOURCE_LOCATION_HAS_BUILTIN_FILE) && \
60 defined(ERRORS_SOURCE_LOCATION_HAS_BUILTIN_FUNCTION) && \
61 defined(ERRORS_SOURCE_LOCATION_HAS_BUILTIN_LINE) && \
62 defined(ERRORS_SOURCE_LOCATION_NO_BUILTIN_COLUMN)
64 current(
const char *fileName = __builtin_FILE(),
65 const char *functionName = __builtin_FUNCTION(),
66 const uint_least32_t lineNumber = __builtin_LINE(),
67 const uint_least32_t columnOffset = 0)
noexcept
70 current(
const char *fileName =
"unsupported",
71 const char *functionName =
"unsupported",
72 const uint_least32_t lineNumber = 0,
73 const uint_least32_t columnOffset = 0) noexcept
94 return function_name_;
99 constexpr uint_least32_t
line() const noexcept
107 constexpr std::uint_least32_t
column() const noexcept
115 uint_least32_t
column) noexcept
117 , function_name_(function)
123 const char *file_name_ =
"";
124 const char *function_name_ =
"";
125 std::uint_least32_t line_number{};
126 std::uint_least32_t column_{};
The source location.
Definition source_location.hpp:46
constexpr const char * function_name() const noexcept
Returns the function name.
Definition source_location.hpp:92
constexpr std::uint_least32_t column() const noexcept
Returns the column number, or 0 if it is not supported by the compiler.
Definition source_location.hpp:107
constexpr const char * file_name() const noexcept
Returns the file name, or "unsupported" if it is not supported by the compiler.
Definition source_location.hpp:85
constexpr uint_least32_t line() const noexcept
Returns the line number.
Definition source_location.hpp:99
static constexpr source_location current(const char *fileName="unsupported", const char *functionName="unsupported", const uint_least32_t lineNumber=0, const uint_least32_t columnOffset=0) noexcept
Returns the current source location.
Definition source_location.hpp:70