It turns out pack
is quite tricky to make non-recursiveandconstexpr
, but as promised, here is a non-recursive, constexpr
version of unpack
(complete, live example):
It turns out pack
is quite tricky to make non-recursive, but as promised, here is a non-recursive, constexpr
version of unpack
(complete, live example):
It turns out pack
is quite tricky to make non-recursiveandconstexpr
, but as promised, here is a non-recursive, constexpr
version of unpack
(complete, live example):
int val = pack<int>(1, 0, 1);
// 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1
std::cout << unpack(val) << std::endl;
// 0 0 0 0 0 1 0 1
std::cout << unpack<8>(val) << std::endl;
int val = pack<int>(1, 0, 1);
// 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1
std::cout << unpack(val) << std::endl;
// 0 0 0 0 0 1 0 1
std::cout << unpack<8>(val) << std::endl;
int val = pack<int>(1, 0, 1);
// 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1
std::cout << unpack(val) << std::endl;
// 0 0 0 0 0 1 0 1
std::cout << unpack<8>(val) << std::endl;