mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-16 11:48:36 +12:00
Replace src_loc with std::soource_location
This commit is contained in:
parent
2d32ba5ca2
commit
a2dcbb9c13
17 changed files with 146 additions and 290 deletions
|
@ -8,7 +8,7 @@
|
|||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#endif
|
||||
|
||||
template<typename T, uint N>
|
||||
template <typename T, uint N>
|
||||
struct bf_base
|
||||
{
|
||||
using type = T;
|
||||
|
@ -35,7 +35,7 @@ protected:
|
|||
};
|
||||
|
||||
// Bitfield accessor (N bits from I position, 0 is LSB)
|
||||
template<typename T, uint I, uint N>
|
||||
template <typename T, uint I, uint N>
|
||||
struct bf_t : bf_base<T, N>
|
||||
{
|
||||
using type = typename bf_t::type;
|
||||
|
@ -156,8 +156,17 @@ struct bf_t : bf_base<T, N>
|
|||
}
|
||||
};
|
||||
|
||||
template <typename T, uint I, uint N>
|
||||
struct std::common_type<bf_t<T, I, N>, bf_t<T, I, N>> : std::common_type<T> {};
|
||||
|
||||
template <typename T, uint I, uint N, typename T2>
|
||||
struct std::common_type<bf_t<T, I, N>, T2> : std::common_type<T2, std::common_type_t<T>> {};
|
||||
|
||||
template <typename T, uint I, uint N, typename T2>
|
||||
struct std::common_type<T2, bf_t<T, I, N>> : std::common_type<std::common_type_t<T>, T2> {};
|
||||
|
||||
// Field pack (concatenated from left to right)
|
||||
template<typename F = void, typename... Fields>
|
||||
template <typename F = void, typename... Fields>
|
||||
struct cf_t : bf_base<typename F::type, F::bitsize + cf_t<Fields...>::bitsize>
|
||||
{
|
||||
using type = typename cf_t::type;
|
||||
|
@ -198,7 +207,7 @@ struct cf_t : bf_base<typename F::type, F::bitsize + cf_t<Fields...>::bitsize>
|
|||
};
|
||||
|
||||
// Empty field pack (recursion terminator)
|
||||
template<>
|
||||
template <>
|
||||
struct cf_t<void>
|
||||
{
|
||||
static constexpr uint bitsize = 0;
|
||||
|
@ -208,13 +217,13 @@ struct cf_t<void>
|
|||
return 0;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
static constexpr auto extract(const T&) -> decltype(+T())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
static constexpr T insert(T /*value*/)
|
||||
{
|
||||
return 0;
|
||||
|
@ -222,7 +231,7 @@ struct cf_t<void>
|
|||
};
|
||||
|
||||
// Fixed field (provides constant values in field pack)
|
||||
template<typename T, T V, uint N>
|
||||
template <typename T, T V, uint N>
|
||||
struct ff_t : bf_base<T, N>
|
||||
{
|
||||
using type = typename ff_t::type;
|
||||
|
@ -246,7 +255,7 @@ struct ff_t : bf_base<T, N>
|
|||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
template<typename T, uint I, uint N>
|
||||
template <typename T, uint I, uint N>
|
||||
struct fmt_unveil<bf_t<T, I, N>, void>
|
||||
{
|
||||
using type = typename fmt_unveil<std::common_type_t<T>>::type;
|
||||
|
@ -257,7 +266,7 @@ struct fmt_unveil<bf_t<T, I, N>, void>
|
|||
}
|
||||
};
|
||||
|
||||
template<typename F, typename... Fields>
|
||||
template <typename F, typename... Fields>
|
||||
struct fmt_unveil<cf_t<F, Fields...>, void>
|
||||
{
|
||||
using type = typename fmt_unveil<std::common_type_t<typename F::type>>::type;
|
||||
|
@ -268,7 +277,7 @@ struct fmt_unveil<cf_t<F, Fields...>, void>
|
|||
}
|
||||
};
|
||||
|
||||
template<typename T, T V, uint N>
|
||||
template <typename T, T V, uint N>
|
||||
struct fmt_unveil<ff_t<T, V, N>, void>
|
||||
{
|
||||
using type = typename fmt_unveil<std::common_type_t<T>>::type;
|
||||
|
|
|
@ -1163,12 +1163,12 @@ void fs::sync()
|
|||
#endif
|
||||
}
|
||||
|
||||
[[noreturn]] void fs::xnull(const src_loc& loc)
|
||||
[[noreturn]] void fs::xnull(std::source_location loc)
|
||||
{
|
||||
fmt::throw_exception("Null object.%s", loc);
|
||||
}
|
||||
|
||||
[[noreturn]] void fs::xfail(const src_loc& loc)
|
||||
[[noreturn]] void fs::xfail(std::source_location loc)
|
||||
{
|
||||
fmt::throw_exception("Unexpected fs::error %s%s", g_tls_error, loc);
|
||||
}
|
||||
|
|
180
Utilities/File.h
180
Utilities/File.h
|
@ -166,8 +166,8 @@ namespace fs
|
|||
virtual std::unique_ptr<dir_base> open_dir(const std::string& path) = 0;
|
||||
};
|
||||
|
||||
[[noreturn]] void xnull(const src_loc&);
|
||||
[[noreturn]] void xfail(const src_loc&);
|
||||
[[noreturn]] void xnull(std::source_location);
|
||||
[[noreturn]] void xfail(std::source_location);
|
||||
[[noreturn]] void xovfl();
|
||||
|
||||
constexpr struct pod_tag_t{} pod_tag;
|
||||
|
@ -281,35 +281,23 @@ namespace fs
|
|||
}
|
||||
|
||||
// Change file size (possibly appending zero bytes)
|
||||
bool trunc(u64 length,
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
bool trunc(u64 length, std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (!m_file) xnull({line, col, file, func});
|
||||
if (!m_file) xnull(src_loc);
|
||||
return m_file->trunc(length);
|
||||
}
|
||||
|
||||
// Get file information
|
||||
stat_t get_stat(
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
stat_t get_stat(std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (!m_file) xnull({line, col, file, func});
|
||||
if (!m_file) xnull(src_loc);
|
||||
return m_file->get_stat();
|
||||
}
|
||||
|
||||
// Sync file buffers
|
||||
void sync(
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
void sync(std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (!m_file) xnull({line, col, file, func});
|
||||
if (!m_file) xnull(src_loc);
|
||||
return m_file->sync();
|
||||
}
|
||||
|
||||
|
@ -317,117 +305,76 @@ namespace fs
|
|||
bool strict_read_check(u64 offset, u64 size, u64 type_size) const;
|
||||
|
||||
// Read the data from the file and return the amount of data written in buffer
|
||||
u64 read(void* buffer, u64 count,
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
u64 read(void* buffer, u64 count, std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (!m_file) xnull({line, col, file, func});
|
||||
if (!m_file) xnull(src_loc);
|
||||
return m_file->read(buffer, count);
|
||||
}
|
||||
|
||||
// Read the data from the file at specified offset in thread-safe manner
|
||||
u64 read_at(u64 offset, void* buffer, u64 count,
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
u64 read_at(u64 offset, void* buffer, u64 count, std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (!m_file) xnull({line, col, file, func});
|
||||
if (!m_file) xnull(src_loc);
|
||||
return m_file->read_at(offset, buffer, count);
|
||||
}
|
||||
|
||||
// Write the data to the file and return the amount of data actually written
|
||||
u64 write(const void* buffer, u64 count,
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
u64 write(const void* buffer, u64 count, std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (!m_file) xnull({line, col, file, func});
|
||||
if (!m_file) xnull(src_loc);
|
||||
return m_file->write(buffer, count);
|
||||
}
|
||||
|
||||
// Change current position, returns resulting position
|
||||
u64 seek(s64 offset, seek_mode whence = seek_set,
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
u64 seek(s64 offset, seek_mode whence = seek_set, std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (!m_file) xnull({line, col, file, func});
|
||||
if (!m_file) xnull(src_loc);
|
||||
return m_file->seek(offset, whence);
|
||||
}
|
||||
|
||||
// Get file size
|
||||
u64 size(
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
u64 size(std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (!m_file) xnull({line, col, file, func});
|
||||
if (!m_file) xnull(src_loc);
|
||||
return m_file->size();
|
||||
}
|
||||
|
||||
// Get current position
|
||||
u64 pos(
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
u64 pos(std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (!m_file) xnull({line, col, file, func});
|
||||
if (!m_file) xnull(src_loc);
|
||||
return m_file->seek(0, seek_cur);
|
||||
}
|
||||
|
||||
// Write std::basic_string unconditionally
|
||||
template <typename T> requires (std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>)
|
||||
const file& write(const std::basic_string<T>& str,
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
const file& write(const std::basic_string<T>& str, std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (write(str.data(), str.size() * sizeof(T), line, col, file, func) != str.size() * sizeof(T)) xfail({line, col, file, func});
|
||||
if (write(str.data(), str.size() * sizeof(T), src_loc) != str.size() * sizeof(T)) xfail(src_loc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Write POD unconditionally
|
||||
template <typename T> requires (std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>)
|
||||
const file& write(const T& data,
|
||||
pod_tag_t = pod_tag,
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
const file& write(const T& data, std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (write(std::addressof(data), sizeof(T), line, col, file, func) != sizeof(T)) xfail({line, col, file, func});
|
||||
if (write(std::addressof(data), sizeof(T), src_loc) != sizeof(T)) xfail(src_loc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Write POD std::vector unconditionally
|
||||
template <typename T> requires (std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>)
|
||||
const file& write(const std::vector<T>& vec,
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
const file& write(const std::vector<T>& vec, std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (write(vec.data(), vec.size() * sizeof(T), line, col, file, func) != vec.size() * sizeof(T)) xfail({line, col, file, func});
|
||||
if (write(vec.data(), vec.size() * sizeof(T), src_loc) != vec.size() * sizeof(T)) xfail(src_loc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Read std::basic_string
|
||||
template <typename T> requires (std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>)
|
||||
bool read(std::basic_string<T>& str, usz _size = umax,
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION(),
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN()) const
|
||||
bool read(std::basic_string<T>& str, usz _size = umax, std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (!m_file) xnull({line, col, file, func});
|
||||
if (!m_file) xnull(src_loc);
|
||||
|
||||
if (_size != umax)
|
||||
{
|
||||
|
@ -440,30 +387,22 @@ namespace fs
|
|||
str.resize(_size);
|
||||
}
|
||||
|
||||
return read(str.data(), sizeof(T) * str.size(), line, col, file, func) == sizeof(T) * str.size();
|
||||
return read(str.data(), sizeof(T) * str.size(), src_loc) == sizeof(T) * str.size();
|
||||
}
|
||||
|
||||
// Read POD, sizeof(T) is used
|
||||
template <typename T> requires (std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>)
|
||||
bool read(T& data,
|
||||
pod_tag_t = pod_tag,
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
pod_tag_t = pod_tag, std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
return read(std::addressof(data), sizeof(T), line, col, file, func) == sizeof(T);
|
||||
return read(std::addressof(data), sizeof(T), src_loc) == sizeof(T);
|
||||
}
|
||||
|
||||
// Read POD std::vector
|
||||
template <typename T> requires (std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>)
|
||||
bool read(std::vector<T>& vec, usz _size = umax, bool use_offs = false, usz offset = umax,
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION(),
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN()) const
|
||||
bool read(std::vector<T>& vec, usz _size = umax, bool use_offs = false, usz offset = umax, std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (!m_file) xnull({line, col, file, func});
|
||||
if (!m_file) xnull(src_loc);
|
||||
|
||||
if (_size != umax)
|
||||
{
|
||||
|
@ -478,52 +417,39 @@ namespace fs
|
|||
|
||||
if (use_offs)
|
||||
{
|
||||
return read_at(offset, vec.data(), sizeof(T) * vec.size(), line, col, file, func) == sizeof(T) * vec.size();
|
||||
return read_at(offset, vec.data(), sizeof(T) * vec.size(), src_loc) == sizeof(T) * vec.size();
|
||||
}
|
||||
|
||||
return read(vec.data(), sizeof(T) * vec.size(), line, col, file, func) == sizeof(T) * vec.size();
|
||||
return read(vec.data(), sizeof(T) * vec.size(), src_loc) == sizeof(T) * vec.size();
|
||||
}
|
||||
|
||||
// Read POD (experimental)
|
||||
template <typename T> requires (std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>)
|
||||
T read(
|
||||
pod_tag_t = pod_tag,
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
T read(pod_tag_t = pod_tag, std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
T result;
|
||||
if (!read(result, pod_tag, line, col, file, func)) xfail({line, col, file, func});
|
||||
if (!read(result, pod_tag, src_loc)) xfail(src_loc);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Read full file to std::basic_string
|
||||
template <typename T = char>
|
||||
std::basic_string<T> to_string(
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
std::basic_string<T> to_string(std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
std::basic_string<T> result;
|
||||
result.resize(size() / sizeof(T));
|
||||
seek(0);
|
||||
if (!read(result, result.size(), file, func, line, col)) xfail({line, col, file, func});
|
||||
if (!read(result, result.size(), src_loc)) xfail(src_loc);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Read full file to std::vector
|
||||
template<typename T> requires (std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>)
|
||||
std::vector<T> to_vector(
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
std::vector<T> to_vector(std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
std::vector<T> result;
|
||||
result.resize(size() / sizeof(T));
|
||||
if (!read(result, result.size(), true, 0, file, func, line, col)) xfail({line, col, file, func});
|
||||
if (!read(result, result.size(), true, 0, src_loc)) xfail(src_loc);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -534,13 +460,9 @@ namespace fs
|
|||
file_id get_id() const;
|
||||
|
||||
// Gathered write
|
||||
u64 write_gather(const iovec_clone* buffers, u64 buf_count,
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
u64 write_gather(const iovec_clone* buffers, u64 buf_count, std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (!m_file) xnull({line, col, file, func});
|
||||
if (!m_file) xnull(src_loc);
|
||||
return m_file->write_gather(buffers, buf_count);
|
||||
}
|
||||
};
|
||||
|
@ -584,24 +506,16 @@ namespace fs
|
|||
}
|
||||
|
||||
// Get next directory entry
|
||||
bool read(dir_entry& out,
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
bool read(dir_entry& out, std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (!m_dir) xnull({line, col, file, func});
|
||||
if (!m_dir) xnull(src_loc);
|
||||
return m_dir->read(out);
|
||||
}
|
||||
|
||||
// Reset to the beginning
|
||||
void rewind(
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
void rewind(std::source_location src_loc = std::source_location::current()) const
|
||||
{
|
||||
if (!m_dir) xnull({line, col, file, func});
|
||||
if (!m_dir) xnull(src_loc);
|
||||
return m_dir->rewind();
|
||||
}
|
||||
|
||||
|
|
|
@ -414,22 +414,35 @@ void fmt_class_string<s128>::format(std::string& out, u64 arg)
|
|||
}
|
||||
|
||||
template <>
|
||||
void fmt_class_string<src_loc>::format(std::string& out, u64 arg)
|
||||
void fmt_class_string<std::source_location>::format(std::string& out, u64 arg)
|
||||
{
|
||||
const src_loc& loc = get_object(arg);
|
||||
const std::source_location& loc = get_object(arg);
|
||||
|
||||
if (loc.col != umax)
|
||||
auto is_valid = [](auto num)
|
||||
{
|
||||
fmt::append(out, "\n(in file %s:%u[:%u]", loc.file, loc.line, loc.col);
|
||||
return num && num != umax;
|
||||
};
|
||||
|
||||
const bool has_line = is_valid(loc.line());
|
||||
|
||||
if (has_line && is_valid(loc.column()))
|
||||
{
|
||||
fmt::append(out, "\n(in file %s:%u[:%u]", loc.file_name(), loc.line(), loc.column());
|
||||
}
|
||||
else if (has_line)
|
||||
{
|
||||
fmt::append(out, "\n(in file %s:%u", loc.file_name(), loc.line());
|
||||
}
|
||||
// Let's not care about such useless corner cases
|
||||
// else if (is_valid(loc.column())
|
||||
else
|
||||
{
|
||||
fmt::append(out, "\n(in file %s:%u", loc.file, loc.line);
|
||||
fmt::append(out, "\n(in file %s", loc.file_name());
|
||||
}
|
||||
|
||||
if (loc.func && *loc.func)
|
||||
if (auto func = loc.function_name(); func && func[0])
|
||||
{
|
||||
fmt::append(out, ", in function %s)", loc.func);
|
||||
fmt::append(out, ", in function %s)", func);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -452,14 +465,14 @@ void fmt_class_string<src_loc>::format(std::string& out, u64 arg)
|
|||
|
||||
namespace fmt
|
||||
{
|
||||
[[noreturn]] void raw_verify_error(const src_loc& loc, const char8_t* msg)
|
||||
[[noreturn]] void raw_verify_error(std::source_location loc, const char8_t* msg)
|
||||
{
|
||||
std::string out;
|
||||
fmt::append(out, "%s%s", msg ? msg : u8"Verification failed", loc);
|
||||
thread_ctrl::emergency_exit(out);
|
||||
}
|
||||
|
||||
[[noreturn]] void raw_throw_exception(const src_loc& loc, const char* fmt, const fmt_type_info* sup, const u64* args)
|
||||
[[noreturn]] void raw_throw_exception(std::source_location loc, const char* fmt, const fmt_type_info* sup, const u64* args)
|
||||
{
|
||||
std::string out;
|
||||
raw_append(out, fmt, sup, args);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue