diff --git a/doc/css/metal.css b/doc/css/metal.css index bb1e0669..1c34b405 100644 --- a/doc/css/metal.css +++ b/doc/css/metal.css @@ -98,14 +98,22 @@ html, body { h1:hover > a.anchor:after, h2:hover > a.anchor:after, h3:hover > a.anchor:after { - content: "ยง"; + content: ""; position: absolute; - width: 1em; - left: -1em; top: 65px; + height: 1.1em; + width: 100%; cursor: pointer; } +@media (max-width: 767px) { + h1:hover > a.anchor:after, + h2:hover > a.anchor:after, + h3:hover > a.anchor:after { + top: 120px; + } +} + .page-header + .sub-page-header { margin-top: -15px; } @@ -120,6 +128,12 @@ a.anchor { top: -65px; } +@media (max-width: 767px) { + a.anchor { + top: -120px; + } +} + a:focus { outline: none; } diff --git a/example/src/list.cpp b/example/src/list.cpp index 8eba6e66..16fa1d12 100644 --- a/example/src/list.cpp +++ b/example/src/list.cpp @@ -8,16 +8,16 @@ HIDE( /// [list1] -using list = metal::list<>; // an empty list +using l = metal::list<>; // an empty list /// [list1] -IS_SAME(metal::is_list, metal::true_); +IS_SAME(metal::is_list, metal::true_); ) HIDE( /// [list2] -using list = metal::list; +using l = metal::list; /// [list2] -IS_SAME(metal::is_list, metal::true_); +IS_SAME(metal::is_list, metal::true_); ) diff --git a/example/src/map.cpp b/example/src/map.cpp index 05d8dc8d..ae41d97c 100644 --- a/example/src/map.cpp +++ b/example/src/map.cpp @@ -8,21 +8,21 @@ HIDE( /// [map1] -using map = metal::list<>; // an empty map +using m = metal::list<>; // an empty map /// [map1] -IS_SAME(metal::is_map, metal::true_); +IS_SAME(metal::is_map, metal::true_); ) HIDE( /// [map2] -using map = metal::list< +using m = metal::list< metal::list, metal::list >; /// [map2] -IS_SAME(metal::is_map, metal::true_); +IS_SAME(metal::is_map, metal::true_); ) HIDE( @@ -47,28 +47,119 @@ using not_a_map = metal::list< // not a list of pairs IS_SAME(metal::is_map, metal::false_); ) +HIDE( +/// [is_map] +using m = metal::map< + metal::pair>, + metal::pair>, + metal::pair> +>; + +IS_SAME(metal::is_map, metal::true_); +IS_SAME(metal::is_map>, metal::true_); +IS_SAME(metal::is_map>, metal::false_); +/// [is_map] +) + +HIDE( +/// [order] +using m = metal::map< + metal::pair>, + metal::pair>, + metal::pair> +>; + +IS_SAME(metal::order, metal::number<0>); +IS_SAME(metal::order, metal::number<1>); +IS_SAME(metal::order, metal::number<2>); +/// [order] +) + +HIDE( +/// [has_key] +using m = metal::map< + metal::pair>, + metal::pair>, + metal::pair> +>; + +IS_SAME(metal::has_key, metal::true_); +IS_SAME(metal::has_key, metal::true_); +IS_SAME(metal::has_key, metal::true_); +IS_SAME(metal::has_key, metal::false_); +/// [has_key] +) + +HIDE( +/// [at_key] +using m = metal::map< + metal::pair>, + metal::pair>, + metal::pair> +>; + +IS_SAME(metal::at_key, metal::number); +IS_SAME(metal::at_key, metal::number); +IS_SAME(metal::at_key, metal::number); +/// [at_key] +) + +HIDE( +/// [erase_key] +using m = metal::map< + metal::pair>, + metal::pair>, + metal::pair> +>; + +IS_SAME( + metal::erase_key, + metal::map< + metal::pair>, + metal::pair> + > +); + +IS_SAME( + metal::erase_key, + metal::map< + metal::pair>, + metal::pair> + > +); + +IS_SAME( + metal::erase_key, + metal::map< + metal::pair>, + metal::pair> + > +); +/// [erase_key] +) + HIDE( /// [keys] -using map = metal::map< +using m = metal::map< metal::pair>, metal::pair>, metal::pair> >; -IS_SAME(metal::keys, metal::list); +IS_SAME(metal::keys, metal::list); /// [keys] ) HIDE( /// [values] -using map = metal::map< +using m = metal::map< metal::pair>, metal::pair>, metal::pair> >; IS_SAME( - metal::values, + metal::values, metal::list< metal::number, metal::number, diff --git a/example/src/pair.cpp b/example/src/pair.cpp index c3099ecf..5b2e98c3 100644 --- a/example/src/pair.cpp +++ b/example/src/pair.cpp @@ -8,16 +8,17 @@ HIDE( /// [pair1] -using pair = metal::list; +using p = metal::list; /// [pair1] -IS_SAME(metal::is_pair, metal::true_); +IS_SAME(metal::is_pair

, metal::true_); ) HIDE( /// [is_pair] -IS_SAME(metal::is_pair>, metal::true_); -IS_SAME(metal::is_pair>, metal::false_); +IS_SAME(metal::is_pair>, metal::true_); +IS_SAME(metal::is_pair>, metal::true_); +IS_SAME(metal::is_pair>, metal::false_); /// [is_pair] ) diff --git a/include/metal/config/version.hpp b/include/metal/config/version.hpp index 321871b8..90e13571 100644 --- a/include/metal/config/version.hpp +++ b/include/metal/config/version.hpp @@ -30,7 +30,7 @@ /// /// ### See Also /// \see [Semantic Versioning](http://semver.org/) -#define METAL_PATCH 0 +#define METAL_PATCH 1 /// \ingroup config /// \hideinitializer diff --git a/include/metal/detail/declptr.hpp b/include/metal/detail/declptr.hpp index 63a6c4ee..fe84ca6d 100644 --- a/include/metal/detail/declptr.hpp +++ b/include/metal/detail/declptr.hpp @@ -10,9 +10,7 @@ namespace metal namespace detail { template - constexpr T* declptr() { - return nullptr; - } + T* declptr(); } } diff --git a/include/metal/detail/fold_cons.hpp b/include/metal/detail/fold_cons.hpp index 9b33b0de..41dcd271 100644 --- a/include/metal/detail/fold_cons.hpp +++ b/include/metal/detail/fold_cons.hpp @@ -19,31 +19,117 @@ namespace metal {}; template< - typename a, typename b, typename c, typename d, - typename e, typename f, typename g, typename h, - typename i, typename j, typename k, typename l, - typename m, typename n, typename o, typename p, typename tail, + typename _00, typename _01, typename _02, typename _03, + typename _04, typename _05, typename _06, typename _07, + typename _08, typename _09, typename _10, typename _11, + typename _12, typename _13, typename _14, typename _15, + typename _16, typename _17, typename _18, typename _19, + typename _20, typename _21, typename _22, typename _23, + typename _24, typename _25, typename _26, typename _27, + typename _28, typename _29, typename _30, typename _31, + typename _32, typename _33, typename _34, typename _35, + typename _36, typename _37, typename _38, typename _39, + typename _40, typename _41, typename _42, typename _43, + typename _44, typename _45, typename _46, typename _47, + typename _48, typename _49, typename _50, typename _51, + typename _52, typename _53, typename _54, typename _55, + typename _56, typename _57, typename _58, typename _59, + typename _60, typename _61, typename _62, typename _63, + typename _64, typename _65, typename _66, typename _67, + typename _68, typename _69, typename _70, typename _71, + typename _72, typename _73, typename _74, typename _75, + typename _76, typename _77, typename _78, typename _79, + typename _80, typename _81, typename _82, typename _83, + typename _84, typename _85, typename _86, typename _87, + typename _88, typename _89, typename _90, typename _91, + typename _92, typename _93, typename _94, typename _95, + typename _96, typename _97, typename _98, typename _99, + typename tail, typename state, template class expr > struct _fold_cons< - list, + list< + _00, _01, _02, _03, _04, _05, _06, _07, _08, _09, + _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, + _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, + _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, + _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, + _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, + _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, + _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, + _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, + _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, tail + >, state, lambda, is_value< - expr, b>, c>, d>, e>, f>, g>, h>, - i>, j>, k>, l>, m>, n>, o>, p> + expr, _01>, _02>, _03>, _04>, _05>, _06>, _07>, _08>, _09>, + _10>, _11>, _12>, _13>, _14>, _15>, _16>, _17>, _18>, _19>, + _20>, _21>, _22>, _23>, _24>, _25>, _26>, _27>, _28>, _29>, + _30>, _31>, _32>, _33>, _34>, _35>, _36>, _37>, _38>, _39>, + _40>, _41>, _42>, _43>, _44>, _45>, _46>, _47>, _48>, _49>, + _50>, _51>, _52>, _53>, _54>, _55>, _56>, _57>, _58>, _59>, + _60>, _61>, _62>, _63>, _64>, _65>, _66>, _67>, _68>, _69>, + _70>, _71>, _72>, _73>, _74>, _75>, _76>, _77>, _78>, _79>, + _80>, _81>, _82>, _83>, _84>, _85>, _86>, _87>, _88>, _89>, + _90>, _91>, _92>, _93>, _94>, _95>, _96>, _97>, _98>, _99> > > : _fold_cons< tail, - expr, b>, c>, d>, e>, f>, g>, h>, - i>, j>, k>, l>, m>, n>, o>, p>, + expr, _01>, _02>, _03>, _04>, _05>, _06>, _07>, _08>, _09>, + _10>, _11>, _12>, _13>, _14>, _15>, _16>, _17>, _18>, _19>, + _20>, _21>, _22>, _23>, _24>, _25>, _26>, _27>, _28>, _29>, + _30>, _31>, _32>, _33>, _34>, _35>, _36>, _37>, _38>, _39>, + _40>, _41>, _42>, _43>, _44>, _45>, _46>, _47>, _48>, _49>, + _50>, _51>, _52>, _53>, _54>, _55>, _56>, _57>, _58>, _59>, + _60>, _61>, _62>, _63>, _64>, _65>, _66>, _67>, _68>, _69>, + _70>, _71>, _72>, _73>, _74>, _75>, _76>, _77>, _78>, _79>, + _80>, _81>, _82>, _83>, _84>, _85>, _86>, _87>, _88>, _89>, + _90>, _91>, _92>, _93>, _94>, _95>, _96>, _97>, _98>, _99>, + lambda + > + {}; + + template< + typename _00, typename _01, typename _02, typename _03, + typename _04, typename _05, typename _06, typename _07, + typename _08, typename _09, typename tail, + typename state, template class expr + > + struct _fold_cons< + list<_00, _01, _02, _03, _04, _05, _06, _07, _08, _09, tail>, + state, + lambda, + is_value< + expr, _01>, _02>, _03>, _04>, _05>, _06>, _07>, _08>, _09> + > + > : + _fold_cons< + tail, + expr, _01>, _02>, _03>, _04>, _05>, _06>, _07>, _08>, _09>, lambda > {}; diff --git a/include/metal/detail/pick.hpp b/include/metal/detail/pick.hpp deleted file mode 100644 index b6f3135e..00000000 --- a/include/metal/detail/pick.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright Bruno Dutra 2015-2016 -// Distributed under the Boost Software License, Version 1.0. -// See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt - -#ifndef METAL_DETAIL_PICK_HPP -#define METAL_DETAIL_PICK_HPP - -#include -#include -#include -#include - -namespace metal -{ - namespace detail - { - template - struct _pick - {}; - - template<> - struct _pick, list<>> - { - using type = list<>; - }; - - template - struct _pick, list...>> : - _join, list, list<>>...> - {}; - - template - using pick = typename _pick::type; - } -} - -#endif - diff --git a/include/metal/list.hpp b/include/metal/list.hpp index 67e5cde0..39cb3c7b 100644 --- a/include/metal/list.hpp +++ b/include/metal/list.hpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/include/metal/list/copy_if.hpp b/include/metal/list/copy_if.hpp index b2f19d62..e8c319c8 100644 --- a/include/metal/list/copy_if.hpp +++ b/include/metal/list/copy_if.hpp @@ -9,16 +9,47 @@ #include -#include - namespace metal { + namespace detail + { + template + struct _copy_if_impl; + } + /// \ingroup list /// /// ### Description /// ... template - using copy_if = detail::pick>; + using copy_if = + typename detail::_copy_if_impl>::type; +} + +#include +#include +#include +#include + +namespace metal +{ + namespace detail + { + template + struct _copy_if_impl + {}; + + template<> + struct _copy_if_impl, list<>> + { + using type = list<>; + }; + + template + struct _copy_if_impl, list...>> : + _join, list, list<>>...> + {}; + } } #endif diff --git a/include/metal/list/fold_left.hpp b/include/metal/list/fold_left.hpp index 8d4fa71e..47a25e5d 100644 --- a/include/metal/list/fold_left.hpp +++ b/include/metal/list/fold_left.hpp @@ -24,6 +24,7 @@ namespace metal } #include +#include #include @@ -31,41 +32,105 @@ namespace metal { namespace detail { - template - struct _cons_left + template + struct _cons_left_impl : + _cons_left_impl<(n >= 100) ? 100 : (n >= 10) ? 10 : (n >= 1)> {}; - template - using cons_left = typename _cons_left::type; + template<> + struct _cons_left_impl<100> + { + template< + typename _00, typename _01, typename _02, typename _03, + typename _04, typename _05, typename _06, typename _07, + typename _08, typename _09, typename _10, typename _11, + typename _12, typename _13, typename _14, typename _15, + typename _16, typename _17, typename _18, typename _19, + typename _20, typename _21, typename _22, typename _23, + typename _24, typename _25, typename _26, typename _27, + typename _28, typename _29, typename _30, typename _31, + typename _32, typename _33, typename _34, typename _35, + typename _36, typename _37, typename _38, typename _39, + typename _40, typename _41, typename _42, typename _43, + typename _44, typename _45, typename _46, typename _47, + typename _48, typename _49, typename _50, typename _51, + typename _52, typename _53, typename _54, typename _55, + typename _56, typename _57, typename _58, typename _59, + typename _60, typename _61, typename _62, typename _63, + typename _64, typename _65, typename _66, typename _67, + typename _68, typename _69, typename _70, typename _71, + typename _72, typename _73, typename _74, typename _75, + typename _76, typename _77, typename _78, typename _79, + typename _80, typename _81, typename _82, typename _83, + typename _84, typename _85, typename _86, typename _87, + typename _88, typename _89, typename _90, typename _91, + typename _92, typename _93, typename _94, typename _95, + typename _96, typename _97, typename _98, typename _99, + typename... tail + > + using type = list< + _00, _01, _02, _03, _04, _05, _06, _07, _08, _09, + _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, + _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, + _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, + _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, + _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, + _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, + _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, + _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, + _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, + typename _cons_left_impl< + sizeof...(tail) + >::template type + >; + }; - template< - typename a, typename b, typename c, typename d, - typename e, typename f, typename g, typename h, - typename i, typename j, typename k, typename l, - typename m, typename n, typename o, typename p, typename... tail - > - struct _cons_left< - a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, tail... - > + template<> + struct _cons_left_impl<10> { + template< + typename _00, typename _01, typename _02, typename _03, + typename _04, typename _05, typename _06, typename _07, + typename _08, typename _09, typename... tail + > using type = list< - a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, - cons_left + _00, _01, _02, _03, _04, _05, _06, _07, _08, _09, + typename _cons_left_impl< + sizeof...(tail) + >::template type >; }; - template - struct _cons_left + template<> + struct _cons_left_impl<1> { - using type = list>; + template + using type = list< + head, + typename _cons_left_impl< + sizeof...(tail) + >::template type + >; }; template<> - struct _cons_left<> + struct _cons_left_impl<0> { + template using type = list<>; }; + template + struct _cons_left + { + using type = typename _cons_left_impl< + sizeof...(vals) + >::template type; + }; + + template + using cons_left = typename _cons_left::type; + template struct _fold_left {}; diff --git a/include/metal/list/fold_right.hpp b/include/metal/list/fold_right.hpp index 751424ec..ff2e6cc5 100644 --- a/include/metal/list/fold_right.hpp +++ b/include/metal/list/fold_right.hpp @@ -24,6 +24,7 @@ namespace metal } #include +#include #include @@ -31,49 +32,114 @@ namespace metal { namespace detail { - template - struct _cons_right + template + struct _cons_right_impl : + _cons_right_impl<(n >= 100) ? 100 : (n >= 10) ? 10 : (n >= 1)> {}; - template - using cons_right = typename _cons_right::type; + template<> + struct _cons_right_impl<100> + { + template< + typename _, + typename _00, typename _01, typename _02, typename _03, + typename _04, typename _05, typename _06, typename _07, + typename _08, typename _09, typename _10, typename _11, + typename _12, typename _13, typename _14, typename _15, + typename _16, typename _17, typename _18, typename _19, + typename _20, typename _21, typename _22, typename _23, + typename _24, typename _25, typename _26, typename _27, + typename _28, typename _29, typename _30, typename _31, + typename _32, typename _33, typename _34, typename _35, + typename _36, typename _37, typename _38, typename _39, + typename _40, typename _41, typename _42, typename _43, + typename _44, typename _45, typename _46, typename _47, + typename _48, typename _49, typename _50, typename _51, + typename _52, typename _53, typename _54, typename _55, + typename _56, typename _57, typename _58, typename _59, + typename _60, typename _61, typename _62, typename _63, + typename _64, typename _65, typename _66, typename _67, + typename _68, typename _69, typename _70, typename _71, + typename _72, typename _73, typename _74, typename _75, + typename _76, typename _77, typename _78, typename _79, + typename _80, typename _81, typename _82, typename _83, + typename _84, typename _85, typename _86, typename _87, + typename _88, typename _89, typename _90, typename _91, + typename _92, typename _93, typename _94, typename _95, + typename _96, typename _97, typename _98, typename _99, + typename... tail + > + using type = typename _cons_right_impl< + sizeof...(tail) + >::template type< + list< + _99, _98, _97, _96, _95, _94, _93, _92, _91, _90, + _89, _88, _87, _86, _85, _84, _83, _82, _81, _80, + _79, _78, _77, _76, _75, _74, _73, _72, _71, _70, + _69, _68, _67, _66, _65, _64, _63, _62, _61, _60, + _59, _58, _57, _56, _55, _54, _53, _52, _51, _50, + _49, _48, _47, _46, _45, _44, _43, _42, _41, _40, + _39, _38, _37, _36, _35, _34, _33, _32, _31, _30, + _29, _28, _27, _26, _25, _24, _23, _22, _21, _20, + _19, _18, _17, _16, _15, _14, _13, _12, _11, _10, + _09, _08, _07, _06, _05, _04, _03, _02, _01, _00, + _ + >, + tail... + >; + }; - template< - typename _, - typename a, typename b, typename c, typename d, - typename e, typename f, typename g, typename h, - typename i, typename j, typename k, typename l, - typename m, typename n, typename o, typename p, typename... tail - > - struct _cons_right< - _, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, tail... - > + template<> + struct _cons_right_impl<10> { - using type = cons_right< - list, + template< + typename _, + typename _00, typename _01, typename _02, typename _03, + typename _04, typename _05, typename _06, typename _07, + typename _08, typename _09, typename... tail + > + using type = typename _cons_right_impl< + sizeof...(tail) + >::template type< + list<_09, _08, _07, _06, _05, _04, _03, _02, _01, _00, _>, tail... >; }; - template - struct _cons_right<_, head, tail...> + template<> + struct _cons_right_impl<1> { - using type = cons_right, tail...>; + template + using type = typename _cons_right_impl< + sizeof...(tail) + >::template type, tail...>; }; - template - struct _cons_right<_> + template<> + struct _cons_right_impl<0> { + template using type = _; }; + template + struct _cons_right + { + using type = typename _cons_right_impl< + sizeof...(vals) + >::template type, vals...>; + }; + + template + using cons_right = typename _cons_right::type; + template struct _fold_right {}; template struct _fold_right, state, lbd> : - _fold_cons, vals...>, state, lbd> + _fold_cons, state, lbd> {}; } } diff --git a/include/metal/list/join.hpp b/include/metal/list/join.hpp index 5335dc16..b7246104 100644 --- a/include/metal/list/join.hpp +++ b/include/metal/list/join.hpp @@ -7,19 +7,12 @@ #include -#include -#include -#include - namespace metal { namespace detail { - template + template struct _join; - - template - using join = typename _join::type; } /// \ingroup list @@ -27,114 +20,176 @@ namespace metal /// ### Description /// ... template - using join = typename if_< - and_, is_list...>, - detail::_join - >::type; + using join = typename detail::_join::type; +} + +#include +#include +#include +#include +#include +namespace metal +{ namespace detail { - template - struct _join_impl + template< + typename, typename, typename, typename, typename, + typename, typename, typename, typename, typename + > + struct _join10 {}; - template - using join_impl = typename _join_impl::type; - template< - typename... a, typename... b, typename... c, typename... d, - typename... e, typename... f, typename... g, typename... h, - typename... i, typename... j, typename... k, typename... l, - typename... m, typename... n, typename... o, typename... p, - typename... tail + typename... _0, typename... _1, typename... _2, typename... _3, + typename... _4, typename... _5, typename... _6, typename... _7, + typename... _8, typename... _9 > - struct _join_impl< - list, list, list, list, - list, list, list, list, - list, list, list, list, - list, list, list, list, - tail... - > : - _join< - list< - a..., b..., c..., d..., e..., f..., g..., h..., - i..., j..., k..., l..., m..., n..., o..., p... - >, - tail... - > + struct _join10< + list<_0...>, list<_1...>, list<_2...>, list<_3...>, + list<_4...>, list<_5...>, list<_6...>, list<_7...>, + list<_8...>, list<_9...> + > + { + using type = list< + _0..., _1..., _2..., _3..., _4..., + _5..., _6..., _7..., _8..., _9... + + >; + }; + + template + struct _join3 {}; - template - struct _join_impl, list> + template + struct _join3, list<_1...>, list<_2...>> { - using type = list; + using type = list<_0..., _1..., _2...>; }; - template - struct _join + template + struct _join2 {}; -#if !defined(METAL_COMPAT_MODE) - template< - typename a, typename b, typename c, typename d, - typename e, typename f, typename g, typename h, - typename i, typename j, typename k, typename l, - typename m, typename n, typename o, typename p, - typename head, typename... tail - > - struct _join< - a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, - list, list... - > : - _join_impl< - join_impl, - list - > + template + struct _join2, list<_1...>> + { + using type = list<_0..., _1...>; + }; + + template + struct _join_impl : + _join_impl<(n >= 100) ? 100 : (n >= 10) ? 10 : (n >= 1)> {}; -#endif - template< - typename a, typename b, typename c, typename d, - typename e, typename f, typename g, typename h, - typename i, typename j, typename k, typename l, - typename m, typename n, typename o, typename p, - template class... _ - > - struct _join< - a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, - list<>, _<>... - > : - _join_impl + template<> + struct _join_impl<100> + { + template< + typename _00, typename _01, typename _02, typename _03, + typename _04, typename _05, typename _06, typename _07, + typename _08, typename _09, typename _10, typename _11, + typename _12, typename _13, typename _14, typename _15, + typename _16, typename _17, typename _18, typename _19, + typename _20, typename _21, typename _22, typename _23, + typename _24, typename _25, typename _26, typename _27, + typename _28, typename _29, typename _30, typename _31, + typename _32, typename _33, typename _34, typename _35, + typename _36, typename _37, typename _38, typename _39, + typename _40, typename _41, typename _42, typename _43, + typename _44, typename _45, typename _46, typename _47, + typename _48, typename _49, typename _50, typename _51, + typename _52, typename _53, typename _54, typename _55, + typename _56, typename _57, typename _58, typename _59, + typename _60, typename _61, typename _62, typename _63, + typename _64, typename _65, typename _66, typename _67, + typename _68, typename _69, typename _70, typename _71, + typename _72, typename _73, typename _74, typename _75, + typename _76, typename _77, typename _78, typename _79, + typename _80, typename _81, typename _82, typename _83, + typename _84, typename _85, typename _86, typename _87, + typename _88, typename _89, typename _90, typename _91, + typename _92, typename _93, typename _94, typename _95, + typename _96, typename _97, typename _98, typename _99, + typename... tail + > + using type = join< + join< + join<_00, _01, _02, _03, _04, _05, _06, _07, _08, _09>, + join<_10, _11, _12, _13, _14, _15, _16, _17, _18, _19>, + join<_20, _21, _22, _23, _24, _25, _26, _27, _28, _29>, + join<_30, _31, _32, _33, _34, _35, _36, _37, _38, _39>, + join<_40, _41, _42, _43, _44, _45, _46, _47, _48, _49>, + join<_50, _51, _52, _53, _54, _55, _56, _57, _58, _59>, + join<_60, _61, _62, _63, _64, _65, _66, _67, _68, _69>, + join<_70, _71, _72, _73, _74, _75, _76, _77, _78, _79>, + join<_80, _81, _82, _83, _84, _85, _86, _87, _88, _89>, + join<_90, _91, _92, _93, _94, _95, _96, _97, _98, _99> + >, + typename _join_impl::template type + >; + }; + + template<> + struct _join_impl<10> + { + template< + typename _00, typename _01, typename _02, typename _03, + typename _04, typename _05, typename _06, typename _07, + typename _08, typename _09, typename... tail + > + using type = join< + join<_00, _01, _02, _03, _04, _05, _06, _07, _08, _09>, + typename _join_impl::template type + >; + }; + + template<> + struct _join_impl<1> + { + template + using type = join< + head, + typename _join_impl::template type + >; + }; + + template<> + struct _join_impl<0> + { + template + using type = list<>; + }; + + template + struct _join : + _invoke::template type>, seqs...> {}; template< - typename a, typename b, typename c, typename d, - typename e, typename f, typename g, typename h, - typename i, typename j, typename k, typename l, - typename m, typename n, typename o, typename p, typename... tail + typename _00, typename _01, typename _02, typename _03, + typename _04, typename _05, typename _06, typename _07, + typename _08, typename _09 > - struct _join : - _join< - join_impl, - tail... - > + struct _join<_00, _01, _02, _03, _04, _05, _06, _07, _08, _09> : + _join10<_00, _01, _02, _03, _04, _05, _06, _07, _08, _09> {}; - template - struct _join : - _join, tail...> + template + struct _join<_00, _01, _02> : + _join3<_00, _01, _02> {}; - template - struct _join : - _join_impl + template + struct _join<_00, _01> : + _join2<_00, _01> {}; - template - struct _join - { - using type = a; - }; + template + struct _join : + _if_, seq> + {}; } } diff --git a/include/metal/list/range.hpp b/include/metal/list/range.hpp index 0ab5a1cb..82b6094c 100644 --- a/include/metal/list/range.hpp +++ b/include/metal/list/range.hpp @@ -38,14 +38,13 @@ namespace metal } #include -#include +#include #include #include #include #include #include -#include namespace metal { @@ -54,11 +53,14 @@ namespace metal template using void_ = void; template - struct _range_impl + struct _skip {}; + template + using skip = typename _skip::type; + template - struct _range_impl, list<_...>> + struct _skip, list<_...>> { template static list impl(void_<_>*..., value*...); @@ -67,8 +69,9 @@ namespace metal }; template - struct _range : - _range< + struct _range + { + using type = range< range< range, size>, number<0>, @@ -76,24 +79,21 @@ namespace metal >, sub>, sub> - > - {}; + >; + }; template - struct _range, n> : - _pick< - seq, - join< - enumerate, n, number<0>>, - enumerate, sub, n>, number<0>> - > - > - {}; + struct _range, n> + { + using type = + skip, enumerate, sub, n>>>; + }; template - struct _range> : - _range_impl, n>> - {}; + struct _range> + { + using type = skip, n>>; + }; template struct _range, size> diff --git a/include/metal/list/reverse.hpp b/include/metal/list/reverse.hpp index d2df0221..744213f4 100644 --- a/include/metal/list/reverse.hpp +++ b/include/metal/list/reverse.hpp @@ -25,38 +25,93 @@ namespace metal #include #include +#include namespace metal { namespace detail { - template - struct _reverse_impl + template + struct _reverse_impl : + _reverse_impl<(n >= 100) ? 100 : (n >= 10) ? 10 : (n >= 1)> {}; - template< - typename a, typename b, typename c, typename d, - typename e, typename f, typename g, typename h, - typename i, typename j, typename k, typename l, - typename m, typename n, typename o, typename p, typename... tail - > - struct _reverse_impl< - a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, tail... - > : - _join< - typename _reverse_impl::type, - list + template<> + struct _reverse_impl<100> + { + template< + typename _00, typename _01, typename _02, typename _03, + typename _04, typename _05, typename _06, typename _07, + typename _08, typename _09, typename _10, typename _11, + typename _12, typename _13, typename _14, typename _15, + typename _16, typename _17, typename _18, typename _19, + typename _20, typename _21, typename _22, typename _23, + typename _24, typename _25, typename _26, typename _27, + typename _28, typename _29, typename _30, typename _31, + typename _32, typename _33, typename _34, typename _35, + typename _36, typename _37, typename _38, typename _39, + typename _40, typename _41, typename _42, typename _43, + typename _44, typename _45, typename _46, typename _47, + typename _48, typename _49, typename _50, typename _51, + typename _52, typename _53, typename _54, typename _55, + typename _56, typename _57, typename _58, typename _59, + typename _60, typename _61, typename _62, typename _63, + typename _64, typename _65, typename _66, typename _67, + typename _68, typename _69, typename _70, typename _71, + typename _72, typename _73, typename _74, typename _75, + typename _76, typename _77, typename _78, typename _79, + typename _80, typename _81, typename _82, typename _83, + typename _84, typename _85, typename _86, typename _87, + typename _88, typename _89, typename _90, typename _91, + typename _92, typename _93, typename _94, typename _95, + typename _96, typename _97, typename _98, typename _99, + typename... tail > - {}; + using type = join< + typename _reverse_impl::template type, + list< + _99, _98, _97, _96, _95, _94, _93, _92, _91, _90, + _89, _88, _87, _86, _85, _84, _83, _82, _81, _80, + _79, _78, _77, _76, _75, _74, _73, _72, _71, _70, + _69, _68, _67, _66, _65, _64, _63, _62, _61, _60, + _59, _58, _57, _56, _55, _54, _53, _52, _51, _50, + _49, _48, _47, _46, _45, _44, _43, _42, _41, _40, + _39, _38, _37, _36, _35, _34, _33, _32, _31, _30, + _29, _28, _27, _26, _25, _24, _23, _22, _21, _20, + _19, _18, _17, _16, _15, _14, _13, _12, _11, _10, + _09, _08, _07, _06, _05, _04, _03, _02, _01, _00 + > + >; + }; - template - struct _reverse_impl : - _join::type, list> - {}; + template<> + struct _reverse_impl<10> + { + template< + typename _00, typename _01, typename _02, typename _03, + typename _04, typename _05, typename _06, typename _07, + typename _08, typename _09, typename... tail + > + using type = join< + typename _reverse_impl::template type, + list<_09, _08, _07, _06, _05, _04, _03, _02, _01, _00> + >; + }; + + template<> + struct _reverse_impl<1> + { + template + using type = join< + typename _reverse_impl::template type, + list + >; + }; template<> - struct _reverse_impl<> + struct _reverse_impl<0> { + template using type = list<>; }; @@ -65,9 +120,11 @@ namespace metal {}; template - struct _reverse>: - _reverse_impl - {}; + struct _reverse> + { + using type = + typename _reverse_impl::template type; + }; } } diff --git a/include/metal/list/rotate.hpp b/include/metal/list/rotate.hpp new file mode 100644 index 00000000..3553ca10 --- /dev/null +++ b/include/metal/list/rotate.hpp @@ -0,0 +1,139 @@ +// Copyright Bruno Dutra 2015-2016 +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt + +#ifndef METAL_LIST_ROTATE_HPP +#define METAL_LIST_ROTATE_HPP + +#include + +#include + +namespace metal +{ + namespace detail + { + template> + struct _rotate; + } + + /// \ingroup list + /// + /// ### Description + /// ... + template + using rotate = typename detail::_rotate::type; +} + +#include +#include + +namespace metal +{ + namespace detail + { + template + struct _rotate_impl : + _rotate_impl<(n >= 100) ? 100 : (n >= 10) ? 10 : (n >= 1)> + {}; + + template<> + struct _rotate_impl<100> + { + template< + int_ n, + typename _00, typename _01, typename _02, typename _03, + typename _04, typename _05, typename _06, typename _07, + typename _08, typename _09, typename _10, typename _11, + typename _12, typename _13, typename _14, typename _15, + typename _16, typename _17, typename _18, typename _19, + typename _20, typename _21, typename _22, typename _23, + typename _24, typename _25, typename _26, typename _27, + typename _28, typename _29, typename _30, typename _31, + typename _32, typename _33, typename _34, typename _35, + typename _36, typename _37, typename _38, typename _39, + typename _40, typename _41, typename _42, typename _43, + typename _44, typename _45, typename _46, typename _47, + typename _48, typename _49, typename _50, typename _51, + typename _52, typename _53, typename _54, typename _55, + typename _56, typename _57, typename _58, typename _59, + typename _60, typename _61, typename _62, typename _63, + typename _64, typename _65, typename _66, typename _67, + typename _68, typename _69, typename _70, typename _71, + typename _72, typename _73, typename _74, typename _75, + typename _76, typename _77, typename _78, typename _79, + typename _80, typename _81, typename _82, typename _83, + typename _84, typename _85, typename _86, typename _87, + typename _88, typename _89, typename _90, typename _91, + typename _92, typename _93, typename _94, typename _95, + typename _96, typename _97, typename _98, typename _99, + typename... tail + > + using type = typename _rotate_impl<(n - 100)>::template type< + (n - 100), + tail..., + _00, _01, _02, _03, _04, _05, _06, _07, _08, _09, + _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, + _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, + _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, + _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, + _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, + _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, + _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, + _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, + _90, _91, _92, _93, _94, _95, _96, _97, _98, _99 + >; + }; + + template<> + struct _rotate_impl<10> + { + template< + int_ n, + typename _00, typename _01, typename _02, typename _03, + typename _04, typename _05, typename _06, typename _07, + typename _08, typename _09, typename... tail + > + using type = typename _rotate_impl<(n - 10)>::template type< + (n - 10), + tail..., _00, _01, _02, _03, _04, _05, _06, _07, _08, _09 + >; + }; + + template<> + struct _rotate_impl<1> + { + template + using type = typename _rotate_impl<(n - 1)>::template type< + (n - 1), tail..., head + >; + }; + + template<> + struct _rotate_impl<0> + { + template + using type = list; + }; + + template + struct _rotate + {}; + + template + struct _rotate, number, number> + { + static constexpr int_ m = ((n % s) + s*(n < 0)); + + using type = typename _rotate_impl::template type; + }; + + template + struct _rotate, number> + { + using type = list<>; + }; + } +} + +#endif diff --git a/include/metal/list/sort.hpp b/include/metal/list/sort.hpp index ac8479b6..83a6e9a0 100644 --- a/include/metal/list/sort.hpp +++ b/include/metal/list/sort.hpp @@ -52,7 +52,7 @@ namespace metal template class expr > struct _merge, list, lambda, - if_, true_, false_> + if_, false_, true_> > : _merge< join>, list, list, lambda @@ -66,7 +66,7 @@ namespace metal template class expr > struct _merge, list, lambda, - if_, false_, true_> + if_, true_, false_> > : _merge< join>, list, list, lambda diff --git a/include/metal/map/at_key.hpp b/include/metal/map/at_key.hpp index 92d2406d..de7d9777 100644 --- a/include/metal/map/at_key.hpp +++ b/include/metal/map/at_key.hpp @@ -17,7 +17,27 @@ namespace metal /// \ingroup map /// /// ### Description - /// ... + /// Retrieves the value associated with some key in a \map. + /// + /// ### Usage + /// For any \map `m` and \value `k` + /// \code + /// using result = metal::at_key; + /// \endcode + /// + /// \returns: \value + /// \semantics: + /// If `m` associates keys `k_1, ..., k, ..., k_n` to values + /// `v_1, ..., v, ..., v_n`, then + /// \code + /// using result = v; + /// \endcode + /// + /// ### Example + /// \snippet map.cpp at_key + /// + /// ### See Also + /// \see map, has_key, erase_key template using at_key = detail::lookup, keys, key>; } diff --git a/include/metal/map/erase_key.hpp b/include/metal/map/erase_key.hpp index 5e1518d0..0170bf78 100644 --- a/include/metal/map/erase_key.hpp +++ b/include/metal/map/erase_key.hpp @@ -15,7 +15,29 @@ namespace metal /// \ingroup map /// /// ### Description - /// ... + /// Removes the entry associated with some key in a \map. + /// + /// ### Usage + /// For any \map `m` and \value `k` + /// \code + /// using result = metal::erase_key; + /// \endcode + /// + /// \returns: \map + /// \semantics: + /// If `m` associates keys `k_1, ..., k, ..., k_n` to values + /// `v_1, ..., v, ..., v_n`, then + /// \code + /// using result = metal::map< + /// metal::pair, ..., metal::pair + /// >; + /// \endcode + /// + /// ### Example + /// \snippet map.cpp erase_key + /// + /// ### See Also + /// \see map, has_key, at_key template using erase_key = metal::erase>; } diff --git a/include/metal/map/has_key.hpp b/include/metal/map/has_key.hpp index 6ce8243f..02d60d59 100644 --- a/include/metal/map/has_key.hpp +++ b/include/metal/map/has_key.hpp @@ -15,7 +15,30 @@ namespace metal /// \ingroup map /// /// ### Description - /// ... + /// Checks whether a \map contains an entry with some key. + /// + /// ### Usage + /// For any \map `m` and \value `k` + /// \code + /// using result = metal::has_key; + /// \endcode + /// + /// \returns: \number + /// \semantics: + /// If `m` contains an entry with key `k`, then + /// \code + /// using result = metal::true_; + /// \endcode + /// otherwise + /// \code + /// using result = metal::false_; + /// \endcode + /// + /// ### Example + /// \snippet map.cpp has_key + /// + /// ### See Also + /// \see map, at_key, erase_key template using has_key = metal::contains, key>; } diff --git a/include/metal/map/keys.hpp b/include/metal/map/keys.hpp index cfc8b3c7..64b80f99 100644 --- a/include/metal/map/keys.hpp +++ b/include/metal/map/keys.hpp @@ -21,17 +21,17 @@ namespace metal /// Returns a \list of keys contained in a \map. /// /// ### Usage - /// For any \map `map` + /// For any \map `m` /// \code - /// using result = metal::keys; + /// using result = metal::keys; /// \endcode /// /// \returns: \list /// \semantics: - /// If `map` associates keys `key_1, ..., key_n` to values - /// `val_1, ..., val_n`, then + /// If `m` associates keys `k_1, ..., k_n` to values `v_1, ..., v_n`, + /// then /// \code - /// using result = metal::list; + /// using result = metal::list; /// \endcode /// /// ### Example diff --git a/include/metal/map/map.hpp b/include/metal/map/map.hpp index 2cd5e12b..6c7d6e8c 100644 --- a/include/metal/map/map.hpp +++ b/include/metal/map/map.hpp @@ -21,14 +21,40 @@ namespace metal /// \ingroup map /// /// ### Description - /// ... + /// Checks whether some \value is a \map. + /// + /// ### Usage + /// For any \value `val` + /// \code + /// using result = metal::is_map; + /// \endcode + /// + /// \returns: \number + /// \semantics: + /// If `val` is a \map, then + /// \code + /// using result = metal::true_; + /// \endcode + /// otherwise + /// \code + /// using result = metal::false_; + /// \endcode + /// + /// ### Example + /// \snippet map.cpp is_map + /// + /// ### See Also + /// \see map template using is_map = typename detail::_is_map::type; /// \ingroup map /// /// ### Description - /// ... + /// Constructs a \map out of a sequence of \pairs. + /// + /// ### See Also + /// \see is_map template using map = metal::if_< metal::is_map>, diff --git a/include/metal/map/order.hpp b/include/metal/map/order.hpp index 1e209ac8..39407a21 100644 --- a/include/metal/map/order.hpp +++ b/include/metal/map/order.hpp @@ -18,7 +18,26 @@ namespace metal /// \ingroup map /// /// ### Description - /// ... + /// Returns the index of a key in a \map. + /// + /// ### Usage + /// For any \map `m` and \value `k` + /// \code + /// using result = metal::order; + /// \endcode + /// + /// \returns: \number + /// \semantics: + /// If `m` contains an entry with key `k` at index `idx`, then + /// \code + /// using result = idx; + /// \endcode + /// + /// ### Example + /// \snippet map.cpp order + /// + /// ### See Also + /// \see map template using order = metal::at_key< metal::transpose, metal::indices>>, diff --git a/include/metal/map/values.hpp b/include/metal/map/values.hpp index 99b50e08..15949ce0 100644 --- a/include/metal/map/values.hpp +++ b/include/metal/map/values.hpp @@ -21,17 +21,17 @@ namespace metal /// Returns a \list of values contained in a \map. /// /// ### Usage - /// For any \map `map` + /// For any \map `m` /// \code - /// using result = metal::values; + /// using result = metal::values; /// \endcode /// /// \returns: \list /// \semantics: - /// If `map` associates keys `key_1, ..., key_n` to values - /// `val_1, ..., val_n`, then + /// If `m` associates keys `k_1, ..., k_n` to values `v_1, ..., v_n`, + /// then /// \code - /// using result = metal::list; + /// using result = metal::list; /// \endcode /// /// ### Example diff --git a/include/metal/pair/first.hpp b/include/metal/pair/first.hpp index 42f7904a..39d5379c 100644 --- a/include/metal/pair/first.hpp +++ b/include/metal/pair/first.hpp @@ -19,14 +19,14 @@ namespace metal /// Returns the first element of a \pair. /// /// ### Usage - /// For any \pair `pair` + /// For any \pair `p` /// \code - /// using result = metal::first; + /// using result = metal::first

; /// \endcode /// /// \returns: \value /// \semantics: - /// If `pair` contains \values `x` and `y` in that order, then + /// If `p` contains \values `x` and `y` in that order, then /// \code /// using result = x; /// \endcode diff --git a/include/metal/pair/second.hpp b/include/metal/pair/second.hpp index e5e08c58..72533cda 100644 --- a/include/metal/pair/second.hpp +++ b/include/metal/pair/second.hpp @@ -19,14 +19,14 @@ namespace metal /// Returns the second element of a \pair. /// /// ### Usage - /// For any \pair `pair` + /// For any \pair `p` /// \code - /// using result = metal::second; + /// using result = metal::second

; /// \endcode /// /// \returns: \value /// \semantics: - /// If `pair` contains \values `x` and `y` in that order, then + /// If `p` contains \values `x` and `y` in that order, then /// \code /// using result = y; /// \endcode diff --git a/test/src/metal.cpp b/test/src/metal.cpp index 73d2f13d..8929eee4 100644 --- a/test/src/metal.cpp +++ b/test/src/metal.cpp @@ -22,19 +22,21 @@ CHECK((metal::less), (metal::greater)); \ CHECK((metal::if_), (metal::and_)); \ CHECK((metal::if_), (metal::or_)); \ - CHECK((metal::flatten>>), (LIST(M))); \ - CHECK((metal::flatten, metal::lambda>>), (metal::list)); \ CHECK((metal::at>), (VAL(M))); \ - CHECK((metal::fold_left, metal::lambda>), (metal::fold_right, metal::lambda>)); \ CHECK((metal::insert), (metal::append)); \ CHECK((metal::insert), (metal::prepend)); \ CHECK((metal::erase), (metal::take)); \ CHECK((metal::erase), (metal::drop)); \ - CHECK((metal::same>), (TRUE)); \ CHECK((metal::slice>), (LIST(M))); \ - CHECK((metal::range, NUM(M), NUM(0)>), (metal::reverse>)); \ + CHECK((metal::take), (metal::reverse, NUM(CMPL(M))>>)); \ + CHECK((metal::rotate), (metal::join, metal::take>)); \ CHECK((metal::sort, metal::lambda>), (metal::reverse>)); \ - CHECK((metal::transform, metal::quote, metal::_1>, metal::list>), (LIST(M))); \ + CHECK((metal::same>), (TRUE)); \ + CHECK((metal::flatten>>), (LIST(M))); \ + CHECK((metal::flatten, metal::lambda>>), (LIST(M))); \ + CHECK((metal::fold_left, metal::lambda>), (metal::fold_right, metal::lambda>)); \ + CHECK((metal::range, NUM(0)>), (metal::reverse)); \ + CHECK((metal::transform, metal::quote, metal::_1>, metal::indices>), (LIST(M))); \ CHECK((metal::transpose>), (MAP(INC(M)))); \ CHECK((metal::transform, metal::_1>, MAP(M)>), (metal::keys)); \ CHECK((metal::transform, metal::_1>, MAP(M)>), (metal::values)); \ diff --git a/test/src/metal/list/flatten.cpp b/test/src/metal/list/flatten.cpp index 0b9c45e4..56fb228d 100644 --- a/test/src/metal/list/flatten.cpp +++ b/test/src/metal/list/flatten.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "test.hpp" @@ -21,6 +22,7 @@ CHECK((metal::flatten), (PAIR(M))); \ CHECK((metal::flatten), (LIST(M))); \ CHECK((metal::flatten), (metal::list)); \ + CHECK((metal::flatten, NUM(N)>>), (metal::enumerate, NUM(N)>)); \ /**/ GEN(MATRIX) diff --git a/test/src/metal/list/fold_left.cpp b/test/src/metal/list/fold_left.cpp index 6a73b2f7..c46c0481 100644 --- a/test/src/metal/list/fold_left.cpp +++ b/test/src/metal/list/fold_left.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "test.hpp" @@ -63,6 +64,7 @@ CHECK((metal::is_invocable, LBD(_), LBD(N), LBD(N)>), (FALSE)); \ CHECK((metal::is_invocable, LBD(_), LBD(N), LBD(_)>), (FALSE)); \ CHECK((metal::fold_left), (FOLD(M, TAB, VAL(N)))); \ + CHECK((metal::fold_left, NUM(N)>, NUM(2), LBD(2)>), (NUM(2))); \ /**/ GEN(MATRIX) diff --git a/test/src/metal/list/fold_right.cpp b/test/src/metal/list/fold_right.cpp index 755de550..3a56f890 100644 --- a/test/src/metal/list/fold_right.cpp +++ b/test/src/metal/list/fold_right.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "test.hpp" @@ -63,6 +64,7 @@ CHECK((metal::is_invocable, LBD(_), LBD(N), LBD(N)>), (FALSE)); \ CHECK((metal::is_invocable, LBD(_), LBD(N), LBD(_)>), (FALSE)); \ CHECK((metal::fold_right), (REFOLD(M, TAB, VAL(N)))); \ + CHECK((metal::fold_right, NUM(N)>, NUM(2), LBD(2)>), (NUM(2))); \ /**/ GEN(MATRIX) diff --git a/test/src/metal/list/reverse.cpp b/test/src/metal/list/reverse.cpp index 1a391951..5d6afd1e 100644 --- a/test/src/metal/list/reverse.cpp +++ b/test/src/metal/list/reverse.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "test.hpp" @@ -21,6 +22,7 @@ CHECK((metal::reverse), (metal::list)); \ CHECK((metal::reverse), (metal::list)); \ CHECK((metal::reverse), (metal::list)); \ + CHECK((metal::reverse, NUM(N)>>), (metal::enumerate, metal::number<-100*M>, NUM(N)>)); \ /**/ GEN(MATRIX) diff --git a/test/src/metal/list/rotate.cpp b/test/src/metal/list/rotate.cpp new file mode 100644 index 00000000..017cf602 --- /dev/null +++ b/test/src/metal/list/rotate.cpp @@ -0,0 +1,70 @@ +// Copyright Bruno Dutra 2015-2016 +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include +#include +#include + +#include "test.hpp" + +#define MATRIX(M, N) \ + CHECK((metal::is_invocable, VAL(M), VAL(N)>), (FALSE)); \ + CHECK((metal::is_invocable, VAL(M), NUM(N)>), (FALSE)); \ + CHECK((metal::is_invocable, VAL(M), PAIR(N)>), (FALSE)); \ + CHECK((metal::is_invocable, VAL(M), LIST(N)>), (FALSE)); \ + CHECK((metal::is_invocable, VAL(M), MAP(N)>), (FALSE)); \ + CHECK((metal::is_invocable, VAL(M), LBD(N)>), (FALSE)); \ + CHECK((metal::is_invocable, VAL(M), LBD(_)>), (FALSE)); \ + CHECK((metal::is_invocable, NUM(M), VAL(N)>), (FALSE)); \ + CHECK((metal::is_invocable, NUM(M), NUM(N)>), (FALSE)); \ + CHECK((metal::is_invocable, NUM(M), PAIR(N)>), (FALSE)); \ + CHECK((metal::is_invocable, NUM(M), LIST(N)>), (FALSE)); \ + CHECK((metal::is_invocable, NUM(M), MAP(N)>), (FALSE)); \ + CHECK((metal::is_invocable, NUM(M), LBD(N)>), (FALSE)); \ + CHECK((metal::is_invocable, NUM(M), LBD(_)>), (FALSE)); \ + CHECK((metal::is_invocable, PAIR(M), VAL(N)>), (FALSE)); \ + CHECK((metal::is_invocable, PAIR(M), NUM(N)>), (TRUE)); \ + CHECK((metal::is_invocable, PAIR(M), PAIR(N)>), (FALSE)); \ + CHECK((metal::is_invocable, PAIR(M), LIST(N)>), (FALSE)); \ + CHECK((metal::is_invocable, PAIR(M), MAP(N)>), (FALSE)); \ + CHECK((metal::is_invocable, PAIR(M), LBD(N)>), (FALSE)); \ + CHECK((metal::is_invocable, PAIR(M), LBD(_)>), (FALSE)); \ + CHECK((metal::is_invocable, LIST(M), VAL(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LIST(M), NUM(N)>), (TRUE)); \ + CHECK((metal::is_invocable, LIST(M), PAIR(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LIST(M), LIST(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LIST(M), MAP(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LIST(M), LBD(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LIST(M), LBD(_)>), (FALSE)); \ + CHECK((metal::is_invocable, MAP(M), VAL(N)>), (FALSE)); \ + CHECK((metal::is_invocable, MAP(M), NUM(N)>), (TRUE)); \ + CHECK((metal::is_invocable, MAP(M), PAIR(N)>), (FALSE)); \ + CHECK((metal::is_invocable, MAP(M), LIST(N)>), (FALSE)); \ + CHECK((metal::is_invocable, MAP(M), MAP(N)>), (FALSE)); \ + CHECK((metal::is_invocable, MAP(M), LBD(N)>), (FALSE)); \ + CHECK((metal::is_invocable, MAP(M), LBD(_)>), (FALSE)); \ + CHECK((metal::is_invocable, LBD(M), VAL(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LBD(M), NUM(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LBD(M), PAIR(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LBD(M), LIST(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LBD(M), MAP(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LBD(M), LBD(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LBD(M), LBD(_)>), (FALSE)); \ + CHECK((metal::is_invocable, LBD(_), VAL(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LBD(_), NUM(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LBD(_), PAIR(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LBD(_), LIST(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LBD(_), MAP(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LBD(_), LBD(N)>), (FALSE)); \ + CHECK((metal::is_invocable, LBD(_), LBD(_)>), (FALSE)); \ + CHECK((metal::rotate>), (LIST(M))); \ + CHECK((metal::rotate>), (metal::rotate>)); \ + CHECK((metal::rotate, NUM(M)>), (metal::list)); \ + CHECK((metal::rotate>, metal::number<100*N>>, metal::number<-100*N>>), (metal::enumerate>)); \ +/**/ + +GEN(MATRIX)