Skip to content

Instantly share code, notes, and snippets.

@Little-Ki
Last active September 18, 2023 03:47
Show Gist options
  • Save Little-Ki/7b6e1448168883ddfc0de59111740274 to your computer and use it in GitHub Desktop.
Save Little-Ki/7b6e1448168883ddfc0de59111740274 to your computer and use it in GitHub Desktop.
[C++ Template] Make enumrate interval
template<size_t ...args>
struct enumrate_interval_pack {};
template<size_t ...args>
struct enumrate_interval_impl {
using type = enumrate_interval_pack<args...>;
};
template<size_t l, size_t h, size_t ...args>
struct enumrate_interval {
using type = typename std::conditional_t<(l < h), typename enumrate_interval<l, (h - 1), h, args...>, enumrate_interval_impl<h, args...>>::type;
};
template<size_t l, size_t h, size_t ...args>
using enumrate_interval_t = typename enumrate_interval<l, h, args...>::type;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment