2 #include "../utility/assert.h"
3 #include "../utility/meta.h"
4 #include "../utility/parameter.h"
6 #include "../stream/serialize_traits.h"
8 #include "../traits/integral_traits.h"
16 template<
typename T, std::underlying_type_t<T> = (std::numeric_limits<T>::min)(), std::underlying_type_t<T> = (std::numeric_limits<T>::max)()>
27 template<
typename Stream>
33 return writer.template serialize<value_type>(unsigned_value, min, max);
36 template<
typename Stream>
42 BS_ASSERT(reader.template serialize<value_type>(unsigned_value, min, max));
44 value =
static_cast<T
>(unsigned_value);
53 template<
typename T, std::underlying_type_t<T> Min, std::underlying_type_t<T> Max>
59 template<
typename Stream>
65 return writer.template serialize<bound_type>(unsigned_value);
68 template<
typename Stream>
74 BS_ASSERT(reader.template serialize<bound_type>(unsigned_value));
76 value =
static_cast<T
>(unsigned_value);
#define BS_ASSERT(x)
Definition: assert.h:15
std::enable_if_t< T::writing, R > is_writing_t
Definition: meta.h:25
std::enable_if_t< T::reading, R > is_reading_t
Definition: meta.h:28
Definition: bounded_range.h:28
Wrapper type for compiletime known integer bounds.
Definition: enum_trait.h:17
Wrapper type for compiletime known integer bounds.
Definition: integral_traits.h:20
static utility::is_writing_t< Stream > serialize(Stream &writer, T value, value_type min=0, value_type max=(std::numeric_limits< value_type >::max)()) noexcept
Definition: enum_trait.h:29
std::underlying_type_t< T > value_type
Definition: enum_trait.h:25
static utility::is_reading_t< Stream > serialize(Stream &reader, T &value, value_type min=0, value_type max=(std::numeric_limits< value_type >::max)()) noexcept
Definition: enum_trait.h:38
static utility::is_reading_t< Stream > serialize(Stream &reader, T &value) noexcept
Definition: enum_trait.h:70
static utility::is_writing_t< Stream > serialize(Stream &writer, T value) noexcept
Definition: enum_trait.h:61
std::underlying_type_t< T > value_type
Definition: enum_trait.h:56
A class for specializing trait serialization functions.
Definition: serialize_traits.h:11