| 123456789101112131415161718192021222324252627282930313233 |
- #pragma once
- namespace variant { namespace detail {
- // Max of a list of values
- template <size_t T, size_t... Ts> struct static_max;
- template <size_t T> struct static_max<T> {
- static const constexpr size_t value = T;
- };
- template <size_t T1, size_t T2, size_t... Ts>
- struct static_max<T1, T2, Ts...> {
- static const constexpr size_t value =
- T1 > T2 ? static_max<T1, Ts...>::value : static_max<T2, Ts...>::value;
- };
- // Given a typelist of size N, type_index<F>::value will return the inverted
- // offset (i.e. the number of elements that remain after F in the typelist).
- template <typename F, typename... Ts> struct type_index;
- template <typename F> struct type_index<F> {};
- template <typename F, typename T, typename... Ts>
- struct type_index<F, T, Ts...> {
- static const constexpr size_t value = type_index<F, Ts...>::value;
- };
- template <typename F, typename... Ts> struct type_index<F, F, Ts...> {
- static const constexpr size_t value = sizeof...(Ts);
- };
- }}
|