view: parameterise make_byte_view
This commit is contained in:
parent
3dc136595c
commit
d2b36ebded
12
view.hpp
12
view.hpp
@ -565,11 +565,11 @@ namespace util {
|
|||||||
//
|
//
|
||||||
// useful for passing in memory structures to file descriptors and the
|
// useful for passing in memory structures to file descriptors and the
|
||||||
// like. but the consequences of endian conversion is on the user...
|
// like. but the consequences of endian conversion is on the user...
|
||||||
template <typename T>
|
template <typename ByteT = std::byte, typename T>
|
||||||
view<std::byte*>
|
view<ByteT*>
|
||||||
make_byte_view (T &t)
|
make_byte_view (T &t)
|
||||||
{
|
{
|
||||||
auto first = reinterpret_cast<std::byte*> (&t);
|
auto first = reinterpret_cast<ByteT*> (&t);
|
||||||
auto last = first + sizeof (t);
|
auto last = first + sizeof (t);
|
||||||
return { first, last };
|
return { first, last };
|
||||||
}
|
}
|
||||||
@ -582,11 +582,11 @@ namespace util {
|
|||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename ByteT = std::byte, typename T>
|
||||||
view<const std::byte*>
|
view<const ByteT*>
|
||||||
make_byte_view (const T &t)
|
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);
|
auto last = first + sizeof (t);
|
||||||
return { first, last };
|
return { first, last };
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user