view: parameterise make_byte_view

This commit is contained in:
Danny Robson 2018-07-27 18:28:56 +10:00
parent 3dc136595c
commit d2b36ebded

View File

@ -565,11 +565,11 @@ namespace util {
//
// useful for passing in memory structures to file descriptors and the
// like. but the consequences of endian conversion is on the user...
template <typename T>
view<std::byte*>
template <typename ByteT = std::byte, typename T>
view<ByteT*>
make_byte_view (T &t)
{
auto first = reinterpret_cast<std::byte*> (&t);
auto first = reinterpret_cast<ByteT*> (&t);
auto last = first + sizeof (t);
return { first, last };
}
@ -582,11 +582,11 @@ namespace util {
//-------------------------------------------------------------------------
template <typename T>
view<const std::byte*>
template <typename ByteT = std::byte, typename T>
view<const ByteT*>
make_byte_view (const T &t)
{
auto first = reinterpret_cast<std::byte const*> (&t);
auto first = reinterpret_cast<ByteT const*> (&t);
auto last = first + sizeof (t);
return { first, last };
}