12 #ifndef DOCWIRE_SOURCE_LOCATION_H
13 #define DOCWIRE_SOURCE_LOCATION_H
15 #if __has_include(<source_location>) && (!defined(__clang__) || __clang_major__ >= 16)
16 #define USE_STD_SOURCE_LOCATION 1
18 #warning "Cannot use std::source_location, falling back to custom implementation. For best performance, use a C++20 compliant compiler that fully supports std::source_location (e.g., GCC 11+, Clang 16+, MSVC 19.29+)."
19 #define USE_STD_SOURCE_LOCATION 0
23 #if USE_STD_SOURCE_LOCATION
24 #include <source_location>
34 const char* file = __builtin_FILE(),
35 const char*
function = __builtin_FUNCTION(),
36 const std::uint_least32_t line = __builtin_LINE()) noexcept
43 constexpr
const char* file_name()
const noexcept {
return m_file; }
44 constexpr
const char* function_name()
const noexcept {
return m_function; }
45 constexpr std::uint_least32_t line()
const noexcept {
return m_line; }
46 constexpr std::uint_least32_t column()
const noexcept {
return 0; }
49 constexpr
basic_source_location(
const char* file,
const char*
function, std::uint_least32_t line) noexcept
50 : m_file(file), m_function(
function), m_line(line)
53 const char* m_file =
"";
54 const char* m_function =
"";
55 std::uint_least32_t m_line{};
58 #if USE_STD_SOURCE_LOCATION
68 #undef USE_STD_SOURCE_LOCATION
The main namespace for the DocWire SDK.
A fallback implementation of source_location for compilers that do not support std::source_location.