libmorton icon indicating copy to clipboard operation
libmorton copied to clipboard

Supply same uint types overloads or templates

Open WildRackoon opened this issue 2 years ago • 0 comments

Somewhat related to https://github.com/Forceflow/libmorton/issues/41

Having to manage both uint_fast32_t / uint_fast16_t or uint_fast64_t / uint_fast32_t is not easy, especially with templated code:

The following overload: inline void morton2D_32_decode(const uint_fast32_t morton, uint_fast16_t& x, uint_fast16_t& y);

Should also offer the following overload by casting: inline void morton2D_32_decode(const uint_fast32_t morton, uint_fast32_t & x, uint_fast32_t & y);

This brings up the fact that it could use a templated implementation to allow that kind of overloads:

template<typename T, typename U>
inline void morton2D_32_decode(const T morton, U& x, U& y);

Implementation should static_assert that both T and U are unsigned and optionnaly that there are enough std::numeric_limits<>::digits between each other.

WildRackoon avatar Oct 12 '23 13:10 WildRackoon