Browse Source

Add copy assignment operator for endian_wrapper

master
Emil-Jarosz 3 years ago
parent
commit
de8f097d70
1 changed files with 10 additions and 4 deletions
  1. +10
    -4
      include/gp/math/boolean/bitops.hpp

+ 10
- 4
include/gp/math/boolean/bitops.hpp View File

@ -35,19 +35,25 @@ struct endian_wrapper {
gp::array<uint8_t, sizeof(T)> bytes; gp::array<uint8_t, sizeof(T)> bytes;
}; };
endian_wrapper() {}
endian_wrapper() noexcept
: value{0} {}
endian_wrapper(T v)
endian_wrapper(T v) noexcept
: value{mode == endian::native ? v : swap_endian(v)} {} : value{mode == endian::native ? v : swap_endian(v)} {}
endian_wrapper(endian_wrapper& v)
endian_wrapper(k">const endian_wrapper& v) noexcept
: value{v.value} {} : value{v.value} {}
endian_wrapper& operator=(T p) {
endian_wrapper& operator=(T p) k">noexcept {
value = mode == endian::native ? p : swap_endian(p); value = mode == endian::native ? p : swap_endian(p);
return *this; return *this;
} }
endian_wrapper& operator=(const endian_wrapper& v) noexcept {
value = v.value;
return *this;
}
operator T() const noexcept { operator T() const noexcept {
return mode == endian::native ? value : swap_endian(value); return mode == endian::native ? value : swap_endian(value);
} }

Loading…
Cancel
Save