2 #include "../utility/assert.h"
3 #include "../utility/meta.h"
4 #include "../utility/parameter.h"
6 #include "../stream/serialize_traits.h"
25 template<
typename Stream>
30 std::memcpy(&tmp, &value,
sizeof(
float));
32 BS_ASSERT(writer.serialize_bits(tmp, 32));
43 template<
typename Stream>
45 static serialize(Stream& reader,
float& value) noexcept
49 BS_ASSERT(reader.serialize_bits(tmp, 32));
51 std::memcpy(&value, &tmp,
sizeof(
float));
69 template<
typename Stream>
74 std::memcpy(tmp, &value,
sizeof(
double));
76 BS_ASSERT(writer.serialize_bits(tmp[0], 32));
77 BS_ASSERT(writer.serialize_bits(tmp[1], 32));
88 template<
typename Stream>
90 static serialize(Stream& reader,
double& value) noexcept
94 BS_ASSERT(reader.serialize_bits(tmp[0], 32));
95 BS_ASSERT(reader.serialize_bits(tmp[1], 32));
97 std::memcpy(&value, tmp,
sizeof(
double));
#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
std::conditional_t<(sizeof(T)<=16 &&std::is_trivially_copy_constructible_v< T >), std::add_const_t< T >, std::add_lvalue_reference_t< std::add_const_t< T > >> in
Passes by const or const reference depending on size.
Definition: parameter.h:94
static utility::is_reading_t< Stream > serialize(Stream &reader, double &value) noexcept
Serializes a whole double from the reader.
Definition: float_trait.h:90
static utility::is_writing_t< Stream > serialize(Stream &writer, in< double > value) noexcept
Serializes a whole double into the writer.
Definition: float_trait.h:71
static utility::is_writing_t< Stream > serialize(Stream &writer, in< float > value) noexcept
Serializes a whole float into the writer.
Definition: float_trait.h:27
static utility::is_reading_t< Stream > serialize(Stream &reader, float &value) noexcept
Serializes a whole float from the reader.
Definition: float_trait.h:45
A class for specializing trait serialization functions.
Definition: serialize_traits.h:11