Replace src_loc with std::soource_location

This commit is contained in:
Elad Ashkenazi 2024-05-21 10:34:51 +03:00
parent 2d32ba5ca2
commit a2dcbb9c13
17 changed files with 146 additions and 290 deletions

View file

@ -357,7 +357,7 @@ namespace fmt
}
// Internal exception message formatting template, must be explicitly specialized or instantiated in cpp to minimize code bloat
[[noreturn]] void raw_throw_exception(const src_loc&, const char*, const fmt_type_info*, const u64*);
[[noreturn]] void raw_throw_exception(std::source_location, const char*, const fmt_type_info*, const u64*);
// Throw exception with formatting
template <typename CharT, usz N, typename... Args>
@ -366,13 +366,9 @@ namespace fmt
struct args_break_t {};
[[noreturn]] FORCE_INLINE SAFE_BUFFERS() throw_exception(const CharT(&fmt)[N], const Args&... args,
args_break_t = args_break_t{},
u32 line = __builtin_LINE(),
u32 col = __builtin_COLUMN(),
const char* file = __builtin_FILE(),
const char* func = __builtin_FUNCTION())
args_break_t = args_break_t{}, std::source_location src_loc = std::source_location::current())
{
raw_throw_exception({line, col, file, func}, reinterpret_cast<const char*>(fmt), type_info_v<Args...>, fmt_args_t<Args...>{fmt_unveil<Args>::get(args)...});
raw_throw_exception(src_loc, reinterpret_cast<const char*>(fmt), type_info_v<Args...>, fmt_args_t<Args...>{fmt_unveil<Args>::get(args)...});
}
#ifndef _MSC_VER
@ -427,11 +423,7 @@ namespace fmt
// Ensure with formatting
template <typename T, typename CharT, usz N, typename... Args>
decltype(auto) ensure(T&& arg, const CharT(&fmt)[N], tie<Args...> args,
u32 line = __builtin_LINE(),
u32 col = __builtin_COLUMN(),
const char* file = __builtin_FILE(),
const char* func = __builtin_FUNCTION()) noexcept
decltype(auto) ensure(T&& arg, const CharT(&fmt)[N], tie<Args...> args, std::source_location src_loc = std::source_location::current()) noexcept
{
if (std::forward<T>(arg)) [[likely]]
{
@ -442,6 +434,6 @@ namespace fmt
u64 data[sizeof...(Args) + 1];
args.init(data);
raw_throw_exception({line, col, file, func}, reinterpret_cast<const char*>(fmt), type_info_v<std::remove_cvref_t<Args>...>, +data);
raw_throw_exception(src_loc, reinterpret_cast<const char*>(fmt), type_info_v<std::remove_cvref_t<Args>...>, +data);
}
}