diff --git a/deps/ox/src/ox/std/assert.hpp b/deps/ox/src/ox/std/assert.hpp index f15e63a4..95df779b 100644 --- a/deps/ox/src/ox/std/assert.hpp +++ b/deps/ox/src/ox/std/assert.hpp @@ -8,6 +8,12 @@ #pragma once +#if __has_include() +#include +#else +#define assert(e) {} +#endif + #include "defines.hpp" #include "error.hpp" diff --git a/deps/ox/src/ox/std/bstring.hpp b/deps/ox/src/ox/std/bstring.hpp index bc64976c..bb235e4c 100644 --- a/deps/ox/src/ox/std/bstring.hpp +++ b/deps/ox/src/ox/std/bstring.hpp @@ -45,7 +45,7 @@ class BString { constexpr char &operator[](std::size_t i) noexcept; - Error append(const char *str, std::size_t strLen) noexcept; + constexpr Error append(const char *str, std::size_t strLen) noexcept; constexpr char *data() noexcept; @@ -153,14 +153,14 @@ constexpr char &BString::operator[](std::size_t i) noexcept { } template -Error BString::append(const char *str, std::size_t strLen) noexcept { +constexpr Error BString::append(const char *str, std::size_t strLen) noexcept { Error err; auto currentLen = len(); if (cap() < currentLen + strLen + 1) { strLen = cap() - currentLen; err = OxError(1, "Insufficient space for full string"); } - ox_memcpy(m_buff + currentLen, str, strLen); + ox_strncpy(m_buff + currentLen, str, strLen); // make sure last element is a null terminator m_buff[currentLen + strLen] = 0; return err; diff --git a/deps/ox/src/ox/std/fmt.hpp b/deps/ox/src/ox/std/fmt.hpp index 81477eaa..7edff4fc 100644 --- a/deps/ox/src/ox/std/fmt.hpp +++ b/deps/ox/src/ox/std/fmt.hpp @@ -169,8 +169,8 @@ constexpr Fmt fmtSegments(const char *fmt) noexcept { template [[nodiscard]] -StringType sfmt(const char *fmt, Args... args) noexcept { - oxAssert(ox::detail::argCount(fmt) == sizeof...(args), "Argument count mismatch."); +constexpr StringType sfmt(const char *fmt, Args... args) noexcept { + assert(ox::detail::argCount(fmt) == sizeof...(args)); StringType out; const auto fmtSegments = ox::detail::fmtSegments(fmt); const auto &firstSegment = fmtSegments.segments[0];