#include #include "example.hpp" // NOTE: keep in sync with the README /// [tutorial] #include // First we need some Values union x { char payload[10]; }; class y { public: char c; }; struct z { char c; int i; }; // ... from which we construct some Lists using l0 = metal::list<>; using l1 = metal::prepend; using l2 = metal::append; using l3 = metal::insert, y>; static_assert(metal::same>::value, ""); static_assert(metal::same>::value, ""); static_assert(metal::same>::value, ""); // Lists are versatile, we can check their sizes... static_assert(metal::size::value == 0, ""); static_assert(metal::size::value == 1, ""); static_assert(metal::size::value == 2, ""); static_assert(metal::size::value == 3, ""); // retrieve their elements... static_assert(metal::same, x>::value, ""); static_assert(metal::same, z>::value, ""); static_assert(metal::same>, y>::value, ""); // count those that satisfy a predicate... static_assert(metal::count_if>::value == 2, ""); static_assert(metal::count_if>::value == 1, ""); // We can create new Lists by removing elements... using l0_ = metal::drop>; using l1_ = metal::take>; using l2_ = metal::erase>; static_assert(metal::same::value, ""); static_assert(metal::same::value, ""); static_assert(metal::same::value, ""); // by reversing the order of elements... static_assert(metal::same, metal::list<>>::value, ""); static_assert(metal::same, metal::list>::value, ""); static_assert(metal::same, metal::list>::value, ""); static_assert(metal::same, metal::list>::value, ""); // by transforming the elements... using l2ptrs = metal::transform, l2>; using l3refs = metal::transform, l3>; static_assert(metal::same>::value, ""); static_assert(metal::same>::value, ""); // even by sorting them... template using smaller = metal::number<(sizeof(x) < sizeof(y))>; using sorted = metal::sort>; static_assert(metal::same>::value, ""); // that and much more! /// [tutorial]