Compare commits

...

3 Commits

Author SHA1 Message Date
7477ede222 [ox/std] Cleanup some enable_ifs
All checks were successful
Build / build (push) Successful in 1m7s
2026-01-21 23:35:19 -06:00
65e3153dda [ox/std] Add Union_c concept 2026-01-21 23:35:02 -06:00
53a224cf8f [ox/std] Cleanup 2026-01-21 23:34:36 -06:00
3 changed files with 9 additions and 5 deletions

View File

@@ -17,19 +17,19 @@ namespace ox {
template<typename T>
[[nodiscard]]
constexpr T byteSwap(typename enable_if<sizeof(T) == 1, T>::type i) noexcept {
constexpr T byteSwap(T const i) noexcept requires(sizeof(T) == 1) {
return i;
}
template<typename T>
[[nodiscard]]
constexpr T byteSwap(typename enable_if<sizeof(T) == 2, T>::type i) noexcept {
constexpr T byteSwap(T const i) noexcept requires(sizeof(T) == 2) {
return static_cast<T>(i << 8) | static_cast<T>(i >> 8);
}
template<typename T>
[[nodiscard]]
constexpr T byteSwap(typename enable_if<sizeof(T) == 4, T>::type i) noexcept {
constexpr T byteSwap(T const i) noexcept requires(sizeof(T) == 4) {
return ((i >> 24) & 0x000000ff) |
((i >> 8) & 0x0000ff00) |
((i << 8) & 0x00ff0000) |
@@ -38,7 +38,7 @@ constexpr T byteSwap(typename enable_if<sizeof(T) == 4, T>::type i) noexcept {
template<typename T>
[[nodiscard]]
constexpr T byteSwap(typename enable_if<sizeof(T) == 8, T>::type i) noexcept {
constexpr T byteSwap(T const i) noexcept requires(sizeof(T) == 8) {
return ((i >> 56) & 0x00000000000000ff) |
((i >> 40) & 0x000000000000ff00) |
((i >> 24) & 0x0000000000ff0000) |

View File

@@ -32,4 +32,8 @@ concept Integral_c = ox::is_integral_v<T>;
template<typename T, size_t max>
concept IntegerRange_c = ox::is_integer_v<T> && ox::MaxValue<T> >= max;
template<typename Union>
concept Union_c = is_union_v<Union>;
}

View File

@@ -32,7 +32,7 @@ constexpr ox::Error writeItoa(Integer v, ox::Writer_c auto &writer) noexcept {
val %= mod;
mod /= base;
if (it || digit) {
ox::ResizedInt_t<Integer, 64> start = '0';
constexpr auto start = '0';
if (digit >= 10) [[unlikely]] {
digit -= 10;
OX_RETURN_ERROR(writer.put('1'));