[ox/std] Make assert functions take StringViews instead of C strings

This commit is contained in:
Gary Talent 2023-09-02 01:11:40 -05:00
parent 1a7e551025
commit b6f86551e9

View File

@ -22,9 +22,9 @@
namespace ox { namespace ox {
void panic(const char *file, int line, const char *panicMsg, const Error &err = OxError(0)) noexcept; void panic(CRStringView file, int line, CRStringView panicMsg, const Error &err = OxError(0)) noexcept;
constexpr void constexprPanic(const char *file, int line, const char *panicMsg, const Error &err = OxError(0)) noexcept { constexpr void constexprPanic(CRStringView file, int line, CRStringView panicMsg, const Error &err = OxError(0)) noexcept {
if (!std::is_constant_evaluated()) { if (!std::is_constant_evaluated()) {
panic(file, line, panicMsg, err); panic(file, line, panicMsg, err);
} else { } else {
@ -32,7 +32,7 @@ constexpr void constexprPanic(const char *file, int line, const char *panicMsg,
} }
} }
constexpr void assertFunc(const char *file, int line, bool pass, [[maybe_unused]]const char *assertTxt, [[maybe_unused]]const char *msg) noexcept { constexpr void assertFunc(CRStringView file, int line, bool pass, [[maybe_unused]]CRStringView assertTxt, [[maybe_unused]]CRStringView msg) noexcept {
if (!pass) { if (!pass) {
if (!std::is_constant_evaluated()) { if (!std::is_constant_evaluated()) {
#ifdef OX_USE_STDLIB #ifdef OX_USE_STDLIB
@ -51,7 +51,7 @@ constexpr void assertFunc(const char *file, int line, bool pass, [[maybe_unused]
} }
} }
constexpr void assertFunc(const char *file, int line, const Error &err, const char*, const char *assertMsg) noexcept { constexpr void assertFunc(CRStringView file, int line, const Error &err, CRStringView, CRStringView assertMsg) noexcept {
if (err) { if (err) {
if (!std::is_constant_evaluated()) { if (!std::is_constant_evaluated()) {
#if defined(OX_USE_STDLIB) #if defined(OX_USE_STDLIB)
@ -75,7 +75,7 @@ constexpr void assertFunc(const char *file, int line, const Error &err, const ch
} }
} }
constexpr void expect(const char *file, int line, const auto &actual, const auto &expected) noexcept { constexpr void expect(CRStringView file, int line, const auto &actual, const auto &expected) noexcept {
if (actual != expected) { if (actual != expected) {
if (!std::is_constant_evaluated()) { if (!std::is_constant_evaluated()) {
#if defined(OX_USE_STDLIB) #if defined(OX_USE_STDLIB)