[ox/std] Make toCString(std::string) inline in non-C++20 code
This commit is contained in:
parent
fefe8bacc7
commit
5c66f3e0dc
13
deps/ox/src/ox/std/fmt.hpp
vendored
13
deps/ox/src/ox/std/fmt.hpp
vendored
@ -26,16 +26,16 @@
|
|||||||
namespace ox {
|
namespace ox {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
constexpr const char *stringify(const char *s) noexcept {
|
constexpr const char *toCString(const char *s) noexcept {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<std::size_t size>
|
template<std::size_t size>
|
||||||
constexpr const char *stringify(const BString<size> &s) noexcept {
|
constexpr const char *toCString(const BString<size> &s) noexcept {
|
||||||
return s.c_str();
|
return s.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr const char *stringify(const String &s) noexcept {
|
constexpr const char *toCString(const String &s) noexcept {
|
||||||
return s.c_str();
|
return s.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,13 +45,13 @@ constexpr
|
|||||||
#else
|
#else
|
||||||
inline
|
inline
|
||||||
#endif
|
#endif
|
||||||
const char *stringify(const std::string &s) noexcept {
|
const char *toCString(const std::string &s) noexcept {
|
||||||
return s.c_str();
|
return s.c_str();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __has_include(<QString>)
|
#if __has_include(<QString>)
|
||||||
inline const char *stringify(const QString &s) noexcept {
|
inline const char *toCString(const QString &s) noexcept {
|
||||||
return s.toUtf8();
|
return s.toUtf8();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -71,7 +71,7 @@ class FmtArg {
|
|||||||
} else if constexpr(is_integral_v<T>) {
|
} else if constexpr(is_integral_v<T>) {
|
||||||
out = ox_itoa(v, dataStr);
|
out = ox_itoa(v, dataStr);
|
||||||
} else {
|
} else {
|
||||||
out = stringify(v);
|
out = toCString(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,6 +166,7 @@ constexpr Fmt<segementCnt> fmtSegments(const char *fmt) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename StringType = String, typename ...Args>
|
template<typename StringType = String, typename ...Args>
|
||||||
|
[[nodiscard]]
|
||||||
StringType sfmt(const char *fmt, Args... args) noexcept {
|
StringType sfmt(const char *fmt, Args... args) noexcept {
|
||||||
oxAssert(ox::detail::argCount(fmt) == sizeof...(args), "Argument count mismatch.");
|
oxAssert(ox::detail::argCount(fmt) == sizeof...(args), "Argument count mismatch.");
|
||||||
StringType out;
|
StringType out;
|
||||||
|
Loading…
Reference in New Issue
Block a user