Created
July 1, 2014 10:17
-
-
Save ThePhD/a4e89a47af937f41bca7 to your computer and use it in GitHub Desktop.
indices_trick
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
#pragma once | |
#include <Furrovine++/unqualified.h> | |
#include <tuple> | |
namespace Furrovine { | |
template <std::size_t... I> | |
struct indices { typedef indices type; }; | |
template <std::size_t N, std::size_t... I> | |
struct make_indices : public make_indices<N - 1, N - 1, I...> { }; | |
template <std::size_t... I> | |
struct make_indices<0, I...> : public indices<I...>{ }; | |
template <std::size_t N, std::size_t... I> | |
struct make_even_indices : public make_indices<N - 2, N - 2, I...> { }; | |
template <std::size_t... I> | |
struct make_even_indices<0, I...> : public indices<I...>{ }; | |
template <typename... Tn> | |
struct types : make_indices<sizeof...( Tn )> { }; | |
template <typename T> | |
struct tuple_indices : public make_indices<std::tuple_size<typename unqualified<T>::type>::value> { }; | |
template <typename... Tn> | |
struct tuple_types : types<Tn...>, std::false_type { }; | |
template <typename... Tn> | |
struct tuple_types<std::tuple<Tn...>> : types<Tn...>, std::true_type{ }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment