// author: Filip Roséen // source: http://b.atch.se/posts/constexpr-meta-container #ifndef ATCH_TYPE_LIST_HPP #define ATCH_TYPE_LIST_HPP #include #include namespace atch { template using ic = std::integral_constant; template using iseq = std::index_sequence; template using make_iseq = std::make_index_sequence; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template struct type_list { using size_type = std::size_t; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static constexpr size_type size () { return sizeof... (Ts); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template struct at { template struct access_helper : access_helper { }; template struct access_helper { using result = U; }; using result = typename access_helper<0, Ts...>::result; }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template struct push { using result = type_list; }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template struct set { template static auto at_helper (ic) -> typename at::result; static auto at_helper (ic) -> U; template static auto set_helper (iseq) -> type_list {}))...> ; using result = decltype (set_helper (make_iseq {})); }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - struct init { template static auto helper (iseq) -> type_list::result...> ; using result = decltype (helper (make_iseq {})); }; }; } /* namespace atch */ #endif /* include guard */