I am trying to convert the following array of bit masks to a more compact version.
template < typename T >
constexpr T length_mask[];
template <>
constexpr uint64 length_mask < uint64 >[] = {
uint64(0)
, ~uint64(0) >> 56
, ~uint64(0) >> 48
, ~uint64(0) >> 40
, ~uint64(0) >> 32
, ~uint64(0) >> 24
, ~uint64(0) >> 16
, ~uint64(0) >> 8
, ~uint64(0) >> 0
};
Here is what I have...
template < typename T, typename I >
constexpr T length_mask_impl[];
template < typename T, std::size_t... I >
constexpr T length_mask_impl < T, std::index_sequence < I... > >[] = {
~T(0), (~T(0) >> ((sizeof(T) - I - 1) * 8))...
};
I wanted to further simplify this for the client code, so they don't have to write out std::make_index_sequence. How can I do that? I am unable to get the syntax right and not sure if this would work either.
template < typename T >
using length_mask < T > = length_mask_impl < T, std::make_index_sequence < sizeof(T) > >;
That doesn't compile. What should the declaration/definition of length_mask be?