diff --git a/deps/ox/src/ox/model/fieldcounter.hpp b/deps/ox/src/ox/model/fieldcounter.hpp index 92061918..a7983ef7 100644 --- a/deps/ox/src/ox/model/fieldcounter.hpp +++ b/deps/ox/src/ox/model/fieldcounter.hpp @@ -48,13 +48,10 @@ class FieldCounter { }; template -#if __cplusplus >= 202002L -consteval -#endif -int countFields() noexcept { - AllocAlias a = {}; +constexpr int countFields() noexcept { + T t; FieldCounter c; - oxIgnoreError(model(&c, std::bit_cast(&a))); + oxIgnoreError(model(&c, &t)); return c.fields; } diff --git a/deps/ox/src/ox/model/typenamecatcher.hpp b/deps/ox/src/ox/model/typenamecatcher.hpp index 464a091d..1edae1e3 100644 --- a/deps/ox/src/ox/model/typenamecatcher.hpp +++ b/deps/ox/src/ox/model/typenamecatcher.hpp @@ -44,21 +44,18 @@ struct TypeNameCatcher { }; template -#if __cplusplus >= 202002L -consteval -#endif -const char *getModelTypeName() noexcept { - AllocAlias a = {}; +constexpr const char *getModelTypeName() noexcept { + T t; TypeNameCatcher nc; - oxIgnoreError(model(&nc, std::bit_cast(&a))); + oxIgnoreError(model(&nc, &t)); return nc.name; } template constexpr const char *getModelTypeName(T *val) noexcept { TypeNameCatcher nc; - oxIgnoreError(model(&nc, std::bit_cast(&val))); + oxIgnoreError(model(&nc, val)); return nc.name; } -} \ No newline at end of file +} diff --git a/deps/ox/src/ox/std/bit.hpp b/deps/ox/src/ox/std/bit.hpp index 6f7c06f0..ee5add2d 100644 --- a/deps/ox/src/ox/std/bit.hpp +++ b/deps/ox/src/ox/std/bit.hpp @@ -61,8 +61,8 @@ namespace std { #if __cplusplus >= 202002L && !defined(OX_USE_STDLIB) template -constexpr typename ox::enable_if::type bit_cast(From src) noexcept { - return __builtin_bitcast(src); +constexpr typename ox::enable_if::type bit_cast(const From &src) noexcept { + return __builtin_bit_cast(To, src); } #elif __cplusplus < 202002L diff --git a/deps/ox/src/ox/std/error.hpp b/deps/ox/src/ox/std/error.hpp index f0538f21..f5e00923 100644 --- a/deps/ox/src/ox/std/error.hpp +++ b/deps/ox/src/ox/std/error.hpp @@ -172,7 +172,7 @@ constexpr Error toError(const Result &ve) noexcept { constexpr void oxIgnoreError(const ox::Error&) noexcept {} #if __cplusplus >= 202002L #define oxReturnError(x) if (const auto _ox_error = ox::detail::toError(x)) [[unlikely]] return _ox_error -#define oxThrowError(x) if (const auto _ox_error = ox::detail::toError(x)) [[unlikely]] ox::Exception(_ox_error) +#define oxThrowError(x) if (const auto _ox_error = ox::detail::toError(x)) [[unlikely]] throw ox::Exception(_ox_error) #else #define oxReturnError(err) if (const auto _ox_error = ox::detail::toError(err)) return _ox_error #define oxThrowError(err) if (const auto _ox_error = ox::detail::toError(err)) throw ox::Exception(_ox_error) diff --git a/deps/ox/src/ox/std/fmt.hpp b/deps/ox/src/ox/std/fmt.hpp index d2ac76ee..90010f36 100644 --- a/deps/ox/src/ox/std/fmt.hpp +++ b/deps/ox/src/ox/std/fmt.hpp @@ -42,11 +42,7 @@ constexpr const char *toCString(const BasicString &s) noexcept { } #if __has_include() -#if __cplusplus >= 202002L -constexpr -#else inline -#endif const char *toCString(const std::string &s) noexcept { return s.c_str(); } diff --git a/deps/ox/src/ox/std/vector.hpp b/deps/ox/src/ox/std/vector.hpp index e24380d5..5526f4c6 100644 --- a/deps/ox/src/ox/std/vector.hpp +++ b/deps/ox/src/ox/std/vector.hpp @@ -32,31 +32,31 @@ struct SmallVector { protected: constexpr void initItems(T **items, std::size_t cap) noexcept { if (cap <= Size) { - *items = std::bit_cast(m_data); + *items = reinterpret_cast(m_data); } else { - *items = std::bit_cast(new AllocAlias[cap]); + *items = reinterpret_cast(new AllocAlias[cap]); } } constexpr void moveConstructItemsFrom(T **items, SmallVector &src, const std::size_t count, const std::size_t cap) noexcept { if (cap <= Size) { - const auto dstItems = bit_cast(m_data); - const auto srcItems = bit_cast(src.m_data); + const auto dstItems = reinterpret_cast(m_data); + const auto srcItems = reinterpret_cast(src.m_data); for (auto i = 0u; i < count; ++i) { new (&dstItems[i]) T(move(srcItems[i])); } - *items = bit_cast(m_data); + *items = reinterpret_cast(m_data); } } constexpr void moveItemsFrom(T **items, SmallVector &src, const std::size_t count, const std::size_t cap) noexcept { if (cap <= Size) { - const auto dstItems = std::bit_cast(m_data); - const auto srcItems = std::bit_cast(src.m_data); + const auto dstItems = reinterpret_cast(m_data); + const auto srcItems = reinterpret_cast(src.m_data); for (auto i = 0u; i < count; ++i) { dstItems[i] = move(srcItems[i]); } - *items = std::bit_cast(m_data); + *items = reinterpret_cast(m_data); } } @@ -76,7 +76,7 @@ struct SmallVector { SmallVector(SmallVector&&) noexcept = default; protected: constexpr void initItems(T **items, std::size_t cap) noexcept { - *items = std::bit_cast(new AllocAlias[cap]); + *items = reinterpret_cast(new AllocAlias[cap]); } [[maybe_unused]] @@ -382,7 +382,7 @@ Vector::Vector(Vector &&other) noexcept { template Vector::~Vector() { clear(); - this->clearItems(std::bit_cast*>(m_items)); + this->clearItems(reinterpret_cast*>(m_items)); m_items = nullptr; } @@ -403,7 +403,7 @@ template constexpr Vector &Vector::operator=(const Vector &other) { if (this != &other) { clear(); - this->clearItems(std::bit_cast*>(m_items)); + this->clearItems(reinterpret_cast*>(m_items)); m_items = nullptr; m_size = other.m_size; m_cap = other.m_cap; @@ -419,7 +419,7 @@ template constexpr Vector &Vector::operator=(Vector &&other) noexcept { if (this != &other) { clear(); - this->clearItems(std::bit_cast*>(m_items)); + this->clearItems(reinterpret_cast*>(m_items)); m_size = other.m_size; m_cap = other.m_cap; m_items = other.m_items; @@ -445,7 +445,7 @@ template Result Vector::front() noexcept { if (!m_size) { AllocAlias v; - return {*std::bit_cast(&v), OxError(1)}; + return {*reinterpret_cast(&v), OxError(1)}; } return m_items[0]; } @@ -454,7 +454,7 @@ template Result Vector::front() const noexcept { if (!m_size) { AllocAlias v; - return {*std::bit_cast(&v), OxError(1)}; + return {*reinterpret_cast(&v), OxError(1)}; } return m_items[0]; } @@ -463,7 +463,7 @@ template Result Vector::back() noexcept { if (!m_size) { AllocAlias v; - return {*std::bit_cast(&v), OxError(1)}; + return {*reinterpret_cast(&v), OxError(1)}; } return m_items[m_size - 1]; } @@ -472,7 +472,7 @@ template Result Vector::back() const noexcept { if (!m_size) { AllocAlias v; - return {*std::bit_cast(&v), OxError(1)}; + return {*reinterpret_cast(&v), OxError(1)}; } return m_items[m_size - 1]; } @@ -604,7 +604,7 @@ void Vector::expandCap(std::size_t cap) { for (std::size_t i = itRange; i < m_cap; i++) { new (&m_items[i]) T; } - this->clearItems(std::bit_cast*>(oldItems)); + this->clearItems(reinterpret_cast*>(oldItems)); } }