| | #include <metal.hpp> |
| |
|
| | #include <cstdint> |
| | #include <memory> |
| | #include <tuple> |
| |
|
| | #include "example.hpp" |
| |
|
| | HIDE( |
| | |
| | using list = metal::list<>; |
| | |
| |
|
| | IS_SAME(metal::is_list<list>, metal::true_); |
| | ) |
| |
|
| | HIDE( |
| | |
| | using list = metal::list<int, int*, int&>; |
| | |
| |
|
| | IS_SAME(metal::is_list<list>, metal::true_); |
| | ) |
| |
|
| | HIDE( |
| | |
| | using not_a_list = std::tuple<int, int*, int&>; |
| | |
| |
|
| | IS_SAME(metal::is_list<not_a_list>, metal::false_); |
| | ) |
| |
|
| | HIDE( |
| | |
| | IS_SAME(metal::is_list<void>, metal::false_); |
| | IS_SAME(metal::is_list<std::tuple<int, float, void>>, metal::false_); |
| | IS_SAME(metal::is_list<metal::list<int, float, void>>, metal::true_); |
| | IS_SAME(metal::is_list<metal::pair<int, int*>>, metal::true_); |
| | IS_SAME(metal::is_list<metal::map<metal::pair<int, int*>>>, metal::true_); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | IS_SAME(metal::as_list<std::shared_ptr<int>>, metal::list<int>); |
| |
|
| | IS_SAME( |
| | metal::as_list<std::unique_ptr<int>>, |
| | metal::list<int, std::default_delete<int>> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::as_list<std::tuple<int, char, float>>, |
| | metal::list<int, char, float> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME(metal::size<l>, metal::number<6>); |
| | IS_SAME(metal::size<metal::list<>>, metal::number<0>); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME(metal::empty<l>, metal::false_); |
| | IS_SAME(metal::empty<metal::list<>>, metal::true_); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME( |
| | metal::indices<l>, |
| | metal::list< |
| | metal::number<0>, metal::number<1>, metal::number<2>, |
| | metal::number<3>, metal::number<4>, metal::number<5> |
| | > |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME(metal::at<l, metal::number<0>>, short); |
| | IS_SAME(metal::at<l, metal::number<1>>, int); |
| | IS_SAME(metal::at<l, metal::number<2>>, long); |
| | IS_SAME(metal::at<l, metal::number<3>>, float); |
| | IS_SAME(metal::at<l, metal::number<4>>, double); |
| | IS_SAME(metal::at<l, metal::number<5>>, void); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME(metal::front<l>, short); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME(metal::back<l>, void); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<int, int, float, int, void, float>; |
| |
|
| | IS_SAME(metal::contains<l, int>, metal::true_); |
| | IS_SAME(metal::contains<l, float>, metal::true_); |
| | IS_SAME(metal::contains<l, void>, metal::true_); |
| | IS_SAME(metal::contains<l, char>, metal::false_); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<int, int, float, int, void, float>; |
| |
|
| | IS_SAME(metal::count<l, int>, metal::number<3>); |
| | IS_SAME(metal::count<l, float>, metal::number<2>); |
| | IS_SAME(metal::count<l, void>, metal::number<1>); |
| | IS_SAME(metal::count<l, char>, metal::number<0>); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<int, int, float, int, void, float>; |
| |
|
| | IS_SAME(metal::find<l, int>, metal::number<0>); |
| | IS_SAME(metal::find<l, float>, metal::number<2>); |
| | IS_SAME(metal::find<l, void>, metal::number<4>); |
| | IS_SAME(metal::find<l, char>, metal::number<6>); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<int, int, float, int, void, float>; |
| |
|
| | IS_SAME(metal::copy<l, int>, metal::list<int, int, int>); |
| | IS_SAME(metal::copy<l, float>, metal::list<float, float>); |
| | IS_SAME(metal::copy<l, void>, metal::list<void>); |
| | IS_SAME(metal::copy<l, char>, metal::list<>); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<int, int, float, int, void, float>; |
| |
|
| | IS_SAME(metal::remove<l, int>, metal::list<float, void, float>); |
| | IS_SAME(metal::remove<l, float>, metal::list<int, int, int, void>); |
| | IS_SAME(metal::remove<l, void>, metal::list<int, int, float, int, float>); |
| | IS_SAME(metal::remove<l, char>, metal::list<int, int, float, int, void, float>); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<int, int, float, int, void, float>; |
| |
|
| | IS_SAME( |
| | metal::replace<l, float>, |
| | metal::list<int, int, int, void> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::replace<l, float, char>, |
| | metal::list<int, int, char, int, void, char> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::replace<l, float, char, char*>, |
| | metal::list<int, int, char, char*, int, void, char, char*> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME(metal::all_of<l, metal::trait<std::is_fundamental>>, metal::true_); |
| | IS_SAME(metal::all_of<l, metal::trait<std::is_floating_point>>, metal::false_); |
| | IS_SAME(metal::all_of<l, metal::trait<std::is_class>>, metal::false_); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME(metal::any_of<l, metal::trait<std::is_fundamental>>, metal::true_); |
| | IS_SAME(metal::any_of<l, metal::trait<std::is_floating_point>>, metal::true_); |
| | IS_SAME(metal::any_of<l, metal::trait<std::is_class>>, metal::false_); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME(metal::none_of<l, metal::trait<std::is_fundamental>>, metal::false_); |
| | IS_SAME(metal::none_of<l, metal::trait<std::is_floating_point>>, metal::false_); |
| | IS_SAME(metal::none_of<l, metal::trait<std::is_class>>, metal::true_); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME(metal::count_if<l, metal::trait<std::is_fundamental>>, metal::number<6>); |
| | IS_SAME(metal::count_if<l, metal::trait<std::is_floating_point>>, metal::number<2>); |
| | IS_SAME(metal::count_if<l, metal::trait<std::is_class>>, metal::number<0>); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME(metal::find_if<l, metal::trait<std::is_fundamental>>, metal::number<0>); |
| | IS_SAME(metal::find_if<l, metal::trait<std::is_floating_point>>, metal::number<3>); |
| | IS_SAME(metal::find_if<l, metal::trait<std::is_class>>, metal::number<6>); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME( |
| | metal::partition<l, metal::trait<std::is_fundamental>>, |
| | metal::pair<metal::list<short, int, long, float, double, void>, metal::list<>> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::partition<l, metal::trait<std::is_floating_point>>, |
| | metal::pair<metal::list<float, double>, metal::list<short, int, long, void>> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::partition<l, metal::trait<std::is_class>>, |
| | metal::pair<metal::list<>, metal::list<short, int, long, float, double, void>> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME( |
| | metal::copy_if<l, metal::trait<std::is_fundamental>>, |
| | metal::list<short, int, long, float, double, void> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::copy_if<l, metal::trait<std::is_floating_point>>, |
| | metal::list<float, double> |
| | ); |
| |
|
| | IS_SAME(metal::copy_if<l, metal::trait<std::is_class>>, metal::list<>); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME(metal::remove_if<l, metal::trait<std::is_fundamental>>, metal::list<>); |
| |
|
| | IS_SAME( |
| | metal::remove_if<l, metal::trait<std::is_floating_point>>, |
| | metal::list<short, int, long, void> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::remove_if<l, metal::trait<std::is_class>>, |
| | metal::list<short, int, long, float, double, void> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME( |
| | metal::replace_if<l, metal::trait<std::is_fundamental>, char>, |
| | metal::list<char, char, char, char, char, char> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::replace_if<l, metal::trait<std::is_floating_point>, char>, |
| | metal::list<short, int, long, char, char, void> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::replace_if<l, metal::trait<std::is_class>, char>, |
| | metal::list<short, int, long, float, double, void> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using character = metal::list<char, wchar_t, char16_t, char32_t>; |
| | using integral = metal::list<short, int, long, long long>; |
| | using floating = metal::list<float, double, long double>; |
| |
|
| | IS_SAME( |
| | metal::flatten<metal::list<character, integral, floating>>, |
| | metal::list< |
| | char, wchar_t, char16_t, char32_t, |
| | short, int, long, long long, |
| | float, double, long double |
| | > |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using character = metal::list<char, wchar_t, char16_t, char32_t>; |
| | using integral = metal::list<short, int, long, long long>; |
| | using floating = metal::list<float, double, long double>; |
| |
|
| | IS_SAME( |
| | metal::join<character, integral, floating>, |
| | metal::list< |
| | char, wchar_t, char16_t, char32_t, |
| | short, int, long, long long, |
| | float, double, long double |
| | > |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME( |
| | metal::splice<l, metal::number<2>, metal::list<char, char[]>>, |
| | metal::list<short, int, char, char[], long, float, double, void> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME( |
| | metal::insert<l, metal::number<2>, unsigned>, |
| | metal::list<short, int, unsigned, long, float, double, void> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME( |
| | metal::append<l, char, char[]>, |
| | metal::list<short, int, long, float, double, void, char, char[]> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME( |
| | metal::prepend<l, char, char[]>, |
| | metal::list<char, char[], short, int, long, float, double, void> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | IS_SAME( |
| | metal::iota<metal::number<'a'>, metal::number<3>>, |
| | metal::list<metal::number<'a'>, metal::number<'b'>, metal::number<'c'>> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::iota<metal::number<2>, metal::number<3>, metal::number<-5>>, |
| | metal::list<metal::number<2>, metal::number<-3>, metal::number<-8>> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::iota<metal::number<2>, metal::number<-3>, metal::number<-5>>, |
| | metal::list<metal::number<2>, metal::number<7>, metal::number<12>> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | IS_SAME(metal::repeat<void, metal::number<0>>, metal::list<>); |
| | IS_SAME(metal::repeat<void, metal::number<3>>, metal::list<void, void, void>); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME( |
| | metal::slice<l, metal::number<2>, metal::number<3>>, |
| | metal::list<long, float, double> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::slice<l, metal::number<1>, metal::number<2>, metal::number<3>>, |
| | metal::list<int, double> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::slice<l, metal::number<5>, metal::number<-3>, metal::number<2>>, |
| | metal::list<void, float, int> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME( |
| | metal::range<l, metal::number<2>, metal::number<5>>, |
| | metal::list<long, float, double> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::range<l, metal::number<5>, metal::number<2>>, |
| | metal::list<double, float, long> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME( |
| | metal::erase<l, metal::number<2>, metal::number<5>>, |
| | metal::list<short, int, void> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::erase<l, metal::number<5>, metal::number<2>>, |
| | metal::list<short, int, void> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME(metal::drop<l, metal::number<3>>, metal::list<float, double, void>); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME(metal::take<l, metal::number<3>>, metal::list<short, int, long>); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME(metal::reverse<l>, metal::list<void, double, float, long, int, short>); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<short, int, long, float, double, void>; |
| |
|
| | IS_SAME( |
| | metal::rotate<l, metal::number<2>>, |
| | metal::list<long, float, double, void, short, int> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::rotate<l, metal::number<-2>>, |
| | metal::list<double, void, short, int, long, float> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | using l = metal::list<int16_t, int8_t, uint16_t, int32_t, uint32_t, uint8_t>; |
| |
|
| | template<class x, class y> |
| | using smaller = metal::number<sizeof(x) < sizeof(y)>; |
| |
|
| | IS_SAME( |
| | metal::sort<l, metal::lambda<smaller>>, |
| | metal::list<int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t> |
| | ); |
| |
|
| | template<class x, class y> |
| | using not_bigger = metal::number<sizeof(x) <= sizeof(y)>; |
| |
|
| | IS_SAME( |
| | metal::sort<l, metal::lambda<not_bigger>>, |
| | metal::list<uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t> |
| | ); |
| |
|
| | IS_SAME( |
| | metal::sort<metal::numbers<7, -8, -3, 2>>, |
| | metal::sort<metal::numbers<7, -8, -3, 2>, metal::lambda<metal::less>> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | struct a; struct b; struct c; |
| | struct d; struct e; |
| | struct f; struct g; |
| |
|
| | using x = metal::list<a, b>; |
| | using y = metal::list<c, d>; |
| | using z = metal::list<e, f, g>; |
| |
|
| | IS_SAME( |
| | metal::cartesian<x, y, z>, |
| | metal::list< |
| | metal::list<a, c, e>, metal::list<a, c, f>, metal::list<a, c, g>, |
| | metal::list<a, d, e>, metal::list<a, d, f>, metal::list<a, d, g>, |
| | metal::list<b, c, e>, metal::list<b, c, f>, metal::list<b, c, g>, |
| | metal::list<b, d, e>, metal::list<b, d, f>, metal::list<b, d, g> |
| | > |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | struct a; struct b; struct c; struct d; |
| |
|
| | template<class...> struct f {}; |
| | template<class...> struct g {}; |
| | template<class...> struct h {}; |
| |
|
| | using tree = metal::list< |
| | metal::list<metal::list<a>, metal::list<b>>, |
| | metal::list<metal::list<c>, metal::list<d>> |
| | >; |
| |
|
| | IS_SAME( |
| | metal::cascade<tree, metal::lambda<f>, metal::lambda<g>, metal::lambda<h>>, |
| | f<g<h<a>, h<b>>, g<h<c>, h<d>>> |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | struct a; struct b; struct c; struct d; |
| |
|
| | IS_SAME( |
| | metal::combine<metal::list<a, b, c, d>, metal::number<2>>, |
| | metal::list< |
| | metal::list<a, a>, metal::list<a, b>, metal::list<a, c>, metal::list<a, d>, |
| | metal::list<b, a>, metal::list<b, b>, metal::list<b, c>, metal::list<b, d>, |
| | metal::list<c, a>, metal::list<c, b>, metal::list<c, c>, metal::list<c, d>, |
| | metal::list<d, a>, metal::list<d, b>, metal::list<d, c>, metal::list<d, d> |
| | > |
| | ); |
| | |
| | ) |
| |
|
| | HIDE( |
| | |
| | struct a; struct b; struct c; struct d; |
| |
|
| | IS_SAME( |
| | metal::powerset<metal::list<a, b, c, d>>, |
| | metal::list< |
| | metal::list<>, metal::list<a>, metal::list<b>, metal::list<a, b>, |
| | metal::list<c>, metal::list<a, c>, metal::list<b, c>, metal::list<a, b, c>, |
| | metal::list<d>, metal::list<a, d>, metal::list<b, d>, metal::list<a, b, d>, |
| | metal::list<c, d>, metal::list<a, c, d>, metal::list<b, c, d>, |
| | metal::list<a, b, c, d> |
| | > |
| | ); |
| | |
| | ) |
| |
|
| | #if !defined(METAL_WORKAROUND) |
| |
|
| | HIDE( |
| | |
| | using a = metal::list<void(), int, bool, void*>; |
| | using b = metal::list<void(*)(), int& , char, char*>; |
| | using c = metal::list<void(&)(), int&&, long, long*>; |
| |
|
| | IS_SAME( |
| | metal::transform<metal::lazy<std::common_type>, a, b, c>, |
| | metal::list<void(*)(), int, long, void*> |
| | ); |
| | |
| | ) |
| |
|
| | #endif |
| |
|
| | HIDE( |
| | |
| | using l = metal::list< |
| | metal::list<int, int&, int*, int[]>, |
| | metal::list<char, char&, char*, char[]>, |
| | metal::list<float, float&, float*, float[]> |
| | >; |
| |
|
| | IS_SAME( |
| | metal::transpose<l>, |
| | metal::list< |
| | metal::list<int, char, float>, |
| | metal::list<int&, char&, float&>, |
| | metal::list<int*, char*, float*>, |
| | metal::list<int[], char[], float[]> |
| | > |
| | ); |
| | |
| | ) |
| |
|
| | #if !defined(METAL_WORKAROUND) |
| | HIDE( |
| | |
| | template<class val, class num> |
| | using add_extent = val[num::value]; |
| |
|
| | using ext = metal::numbers<3, 5, 2>; |
| |
|
| | IS_SAME(metal::accumulate<metal::lambda<add_extent>, char, ext>, char[2][5][3]); |
| |
|
| | using a = metal::list<int, int&, int*, int[]>; |
| | using b = metal::list<char, char&, char*, char[]>; |
| | using c = metal::list<float, float&, float*, float[]>; |
| |
|
| | IS_SAME( |
| | metal::accumulate<metal::lambda<metal::append>, metal::list<>, a, b, c>, |
| | metal::list< |
| | int, char, float, |
| | int&, char&, float&, |
| | int*, char*, float*, |
| | int[], char[], float[] |
| | > |
| | ); |
| | |
| | ) |
| | #endif |
| |
|