coord/ops: add lshift

This commit is contained in:
Danny Robson 2018-05-04 17:06:18 +10:00
parent b01173d82b
commit 3e5c89f643

View File

@ -1426,7 +1426,23 @@ namespace util {
{
return rshift (k, num, K {fill});
}
}
template <
typename K,
typename = std::enable_if_t<
is_coord_v<K>
>
>
constexpr auto
lshift (const K k, const int places, typename K::value_type fill)
{
K res {};
std::copy_n (std::cbegin (k) + places, K::elements - places, std::begin (res));
std::fill_n (std::begin (res) + K::elements - places, places, fill);
return res;
}
};
///////////////////////////////////////////////////////////////////////////////