6#ifndef MIMICPP_UTILITIES_SOURCE_LOCATION_HPP
7#define MIMICPP_UTILITIES_SOURCE_LOCATION_HPP
17#ifndef MIMICPP_DETAIL_IS_MODULE
19 #include <string_view>
22 #ifdef __cpp_lib_source_location
23 #include <source_location>
24 #define MIMICPP_DETAIL_HAS_SOURCE_LOCATION 1
42#ifdef MIMICPP_DETAIL_HAS_SOURCE_LOCATION
50 [[maybe_unused]]
auto&&... canary,
51 std::source_location
const& loc = std::source_location::current()) noexcept
52 : m_FileName{loc.file_name()},
53 m_FunctionName{loc.function_name()},
56 static_assert(0 ==
sizeof...(canary),
"Do not supply custom arguments to util::SourceLocation.");
68 [[maybe_unused]]
auto&&... canary,
69 std::string_view
const fileName = __builtin_FILE(),
71 std::size_t
const line = __builtin_LINE()) noexcept
76 static_assert(0 ==
sizeof...(canary),
"Do not supply custom arguments to util::SourceLocation.");
86 constexpr std::string_view
file_name() const noexcept
94 return m_FunctionName;
98 constexpr std::size_t
line() const noexcept
106 return lhs.line() == rhs.line()
107 && lhs.file_name() == rhs.file_name()
108 && lhs.function_name() == rhs.function_name();
112 std::string_view m_FileName;
113 std::string_view m_FunctionName;
119struct mimicpp::printing::detail::state::common_type_printer<
mimicpp::util::SourceLocation>
121 template <pr
int_iterator OutIter>
122 static constexpr OutIter
print(OutIter out, util::SourceLocation
const& loc)
124 return detail::print_source_location(
128 loc.function_name());
#define MIMICPP_DETAIL_MODULE_EXPORT
Definition Config.hpp:19
std::string_view const std::string_view const functionName
Definition SourceLocation.hpp:70
~SourceLocation()=default
constexpr std::string_view function_name() const noexcept
Definition SourceLocation.hpp:92
SourceLocation & operator=(SourceLocation &&)=default
std::string_view const fileName
Definition SourceLocation.hpp:69
SourceLocation & operator=(SourceLocation const &)=default
SourceLocation(SourceLocation &&)=default
std::string_view const std::string_view const std::size_t const line
Definition SourceLocation.hpp:71
friend constexpr bool operator==(SourceLocation const &lhs, SourceLocation const &rhs) noexcept
Definition SourceLocation.hpp:104
constexpr std::string_view file_name() const noexcept
Definition SourceLocation.hpp:86
constexpr std::size_t line() const noexcept
Definition SourceLocation.hpp:98
constexpr printing::PrintFn print
Functional object, converting the given object to its textual representation.
Definition Print.hpp:183