view: allow multibyte targets for make_byte_view

This commit is contained in:
Danny Robson 2018-12-19 17:13:47 +11:00
parent 072dce8891
commit f648ad9810

View File

@ -596,22 +596,17 @@ namespace cruft {
/// We have to be careful that rval-references and other temporaries aren't
/// accepted in this signature.
template <
typename WordT = std::byte,
typename WordT = std::byte const,
typename T
>
auto
cruft::view<WordT*>
make_byte_view (T &t)
{
static_assert (sizeof (T) % sizeof (WordT) == 0);
using cursor_type = std::conditional_t<
std::is_const_v<T>,
WordT const*,
WordT*
>;
static_assert (std::is_const_v<T> ? std::is_const_v<WordT> : true);
return view {
cast::alignment<cursor_type> (&t),
cast::alignment<WordT*> (&t),
sizeof (T) / sizeof (WordT)
};
}