view: avoid alignment warnings for view extraction

It is assumed the user is on top of this.
This commit is contained in:
Danny Robson 2018-08-01 13:10:11 +10:00
parent 4b9b292848
commit 47c912e5e2

View File

@ -621,6 +621,8 @@ namespace util {
/// ///
/// the buffer object is advanced in place so that it no longer covers /// the buffer object is advanced in place so that it no longer covers
/// the extract value /// the extract value
///
/// it is assumed the user has taken care of alignment concerns
template < template <
typename ValueT, typename ValueT,
typename ByteT, typename ByteT,
@ -632,7 +634,7 @@ namespace util {
if (buffer.size () < sizeof (ValueT)) if (buffer.size () < sizeof (ValueT))
throw std::runtime_error ("insufficient data for view shift"); throw std::runtime_error ("insufficient data for view shift");
ValueT const &res = *reinterpret_cast<ValueT const*> (buffer.data ()); ValueT const &res = *util::cast::ffs<ValueT const*> (buffer.data ());
buffer = buffer.consume (sizeof (ValueT)); buffer = buffer.consume (sizeof (ValueT));
return res; return res;
} }