123456789101112131415161718192021222324252627282930313233343536373839 |
- #include "simple/support/meta/list.hpp"
- #include <type_traits>
- using namespace simple::support;
- template <typename...> struct some_other_list {};
- int main()
- {
- using a = meta::list<long, int, short, char>;
- static_assert(meta::list_size_v<a> == 4);
- static_assert(std::is_same_v<meta::list_element_t<0, a>, long>);
- static_assert(std::is_same_v<meta::list_element_t<1, a>, int>);
- static_assert(std::is_same_v<meta::list_element_t<2, a>, short>);
- static_assert(std::is_same_v<meta::list_element_t<3, a>, char>);
- static_assert(std::is_same_v<meta::collect_list_t<a, std::index_sequence<1,2>>, meta::list<int, short>>);
- static_assert(std::is_same_v<meta::collect_list_t<a, std::index_sequence<1,3>>, meta::list<int, char>>);
- static_assert(std::is_same_v<meta::collect_list_t<a, std::index_sequence<>>, meta::list<>>);
- static_assert(std::is_same_v<meta::collect_list_t<a, std::index_sequence<1,1>>, meta::list<int, int>>);
- static_assert(std::is_same_v<meta::collect_list_t<a, std::index_sequence<1,2,3,0,0>>,
- meta::list<int, short, char, long, long>>);
- using b = some_other_list<int, char, short>;
- static_assert(meta::list_size_v<b> == 3);
- static_assert(std::is_same_v<meta::list_element_t<0, b>, int>);
- static_assert(std::is_same_v<meta::list_element_t<1, b>, char>);
- static_assert(std::is_same_v<meta::list_element_t<2, b>, short>);
- static_assert(std::is_same_v<meta::collect_list_t<b, std::index_sequence<1,2>>, some_other_list<char, short>>);
- static_assert(std::is_same_v<meta::collect_list_t<b, std::index_sequence<1>>, some_other_list<char>>);
- static_assert(std::is_same_v<meta::collect_list_t<b, std::index_sequence<>>, some_other_list<>>);
- static_assert(std::is_same_v<meta::collect_list_t<b, std::index_sequence<1,1>>, some_other_list<char, char>>);
- static_assert(std::is_same_v<meta::collect_list_t<b, std::index_sequence<1,2,0,0>>,
- some_other_list<char, short, int, int>>);
- return 0;
- }
|