2021-05-11 11:22:36 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef __cpp_lib_source_location
|
|
|
|
#include <source_location>
|
|
|
|
namespace slns = std;
|
|
|
|
#else
|
2021-05-11 11:53:32 +00:00
|
|
|
namespace slns
|
|
|
|
{
|
|
|
|
struct source_location
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static constexpr source_location
|
|
|
|
current(
|
|
|
|
const char* fileName = __builtin_FILE(),
|
|
|
|
const char* functionName = __builtin_FUNCTION(),
|
2021-09-24 16:22:20 +00:00
|
|
|
const uint_least32_t lineNumber = __builtin_LINE()) noexcept
|
2021-05-11 11:53:32 +00:00
|
|
|
{
|
2021-09-24 16:22:20 +00:00
|
|
|
return source_location{fileName, functionName, lineNumber};
|
2021-05-11 11:53:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
source_location(const source_location&) = default;
|
|
|
|
source_location(source_location&&) = default;
|
|
|
|
|
|
|
|
constexpr const char*
|
|
|
|
file_name() const noexcept
|
|
|
|
{
|
|
|
|
return fileName;
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr const char*
|
|
|
|
function_name() const noexcept
|
|
|
|
{
|
|
|
|
return functionName;
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr uint_least32_t
|
|
|
|
line() const noexcept
|
|
|
|
{
|
|
|
|
return lineNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
constexpr explicit source_location(
|
2021-09-24 16:22:20 +00:00
|
|
|
const char* fileName, const char* functionName, const uint_least32_t lineNumber) noexcept
|
|
|
|
: fileName(fileName), functionName(functionName), lineNumber(lineNumber)
|
2021-05-11 11:53:32 +00:00
|
|
|
{}
|
|
|
|
|
2021-09-24 16:22:20 +00:00
|
|
|
const char* const fileName;
|
|
|
|
const char* const functionName;
|
|
|
|
const uint_least32_t lineNumber;
|
2021-05-11 11:53:32 +00:00
|
|
|
};
|
|
|
|
} // namespace slns
|
|
|
|
#endif
|