Last active
September 18, 2023 03:47
-
-
Save Little-Ki/7b6e1448168883ddfc0de59111740274 to your computer and use it in GitHub Desktop.
[C++ Template] Make enumrate interval
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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