File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -407,6 +407,34 @@ namespace detail {
407407 Base::Read (in, val);
408408 }
409409
410+ template <typename Src, typename T>
411+ static inline auto Read (Src& in, T& val) noexcept
412+ -> std::enable_if_t<std::is_signed<T>::value, void> {
413+ using uint_t = std::make_unsigned_t <T>;
414+ uint_t uval;
415+ Base::Read (in, uval);
416+ std::memcpy (&val, &uval, sizeof (T));
417+ }
418+
419+ template <typename T, typename Src>
420+ static inline auto Read (Src& in) noexcept
421+ -> std::enable_if_t<std::is_unsigned<T>::value, T> {
422+ T val;
423+ Base::Read (in, val);
424+ return val;
425+ }
426+
427+ template <typename T, typename Src>
428+ static inline auto Read (Src& in) noexcept
429+ -> std::enable_if_t<std::is_signed<T>::value, T> {
430+ using uint_t = std::make_unsigned_t <T>;
431+ uint_t uval;
432+ Base::Read (in, uval);
433+ T val;
434+ std::memcpy (&val, &uval, sizeof (T));
435+ return val;
436+ }
437+
410438 template <typename Dst>
411439 static inline void Write1 (Dst& out, uint8_t val) noexcept {
412440 Base::Write (out, val);
You can’t perform that action at this time.
0 commit comments