76#if defined __has_builtin
77 #if __has_builtin(__builtin_source_location)
82 #define _INT_SOURCE_LOC_DEF
90 constexpr
unsigned line() const noexcept;
91 constexpr
unsigned column() const noexcept;
99 #ifndef _INT_SOURCE_LOC_DEF
100 const char *_M_file_name =
"";
101 const char *_M_function_name =
"";
102 unsigned _M_line = 0;
103 unsigned _M_column = 0;
108 #
if defined __has_builtin
109 #
if __has_builtin(__builtin_FILE)
110 const char *fileName = __builtin_FILE(),
112 const char *fileName =
"",
114 #
if __has_builtin(__builtin_FUNCTION)
115 const char *functionName = __builtin_FUNCTION(),
117 const char *functionName =
"",
119 #
if __has_builtin(__builtin_LINE)
120 const unsigned lineNumber = __builtin_LINE(),
122 const unsigned lineNumber = 0,
124 #
if __has_builtin(__builtin_COLUMN)
125 const unsigned columnOffset = __builtin_COLUMN()
127 const unsigned columnOffset = 0
131 const char *fileName =
"",
132 const char *functionName =
"",
133 const unsigned lineNumber = 0,
134 const unsigned columnOffset = 0
140 __sl._M_file_name = fileName;
141 __sl._M_function_name = functionName;
142 __sl._M_line = lineNumber;
143 __sl._M_column = columnOffset;
149 constexpr unsigned line()
const noexcept {
return _M_line; }
150 constexpr unsigned column()
const noexcept {
return _M_column; }
151 constexpr const char *
file_name()
const noexcept {
return _M_file_name; }
152 constexpr const char *
function_name()
const noexcept {
return _M_function_name; }
156 const char *_M_file_name;
157 const char *_M_function_name;
162 const __impl *__ptr_ =
nullptr;
169 using __bsl_ty =
decltype(__builtin_source_location());
175 __bsl_ty __ptr = __builtin_source_location())
noexcept {
177 __sl.__ptr_ =
static_cast<const __impl *
>(__ptr);
182 constexpr unsigned line()
const noexcept {
return __ptr_ !=
nullptr ? __ptr_->_M_line : 0; }
183 constexpr unsigned column()
const noexcept {
184 return __ptr_ !=
nullptr ? __ptr_->_M_column : 0;
186 constexpr const char *
file_name()
const noexcept {
187 return __ptr_ !=
nullptr ? __ptr_->_M_file_name :
"";
190 return __ptr_ !=
nullptr ? __ptr_->_M_function_name :
"";
193 #undef _INT_SOURCE_LOC_DEF
Utility class to emulates std::source_location class introduced in c++20 This class provides informat...
static constexpr source_location current() noexcept
Returns the source location where this function is called.
constexpr const char * file_name() const noexcept
Returns the file name of the source location.
constexpr unsigned column() const noexcept
Returns the column offset of the source location.
constexpr unsigned line() const noexcept
Returns the line number of the source location.
constexpr const char * function_name() const noexcept
Returns the function name of the source location.