From d3f4b099d222fe0b3ee1ab279881bcd1fe82da98 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 24 Mar 2017 18:10:07 +0200 Subject: [PATCH] Unroll mp_reverse_fold. --- include/boost/mp11/algorithm.hpp | 6 ++++++ test/mp_reverse_fold.cpp | 23 ++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index 8a83e36..d71b77c 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -796,6 +796,12 @@ template class L, class T1, class... T, class V, template; }; +template class L, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class... T, class V, template class F> struct mp_reverse_fold_impl, V, F> +{ + using rest = typename mp_reverse_fold_impl, V, F>::type; + using type = F>>>>>>>>>; +}; + } // namespace detail template class F> using mp_reverse_fold = typename detail::mp_reverse_fold_impl::type; diff --git a/test/mp_reverse_fold.cpp b/test/mp_reverse_fold.cpp index f88b645..0556bee 100644 --- a/test/mp_reverse_fold.cpp +++ b/test/mp_reverse_fold.cpp @@ -1,5 +1,5 @@ -// Copyright 2015 Peter Dimov. +// Copyright 2015-2017 Peter Dimov. // // Distributed under the Boost Software License, Version 1.0. // @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -55,5 +56,25 @@ int main() BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list<>, rev_push_front>, mp_list>)); } + using boost::mp11::mp_iota_c; + using boost::mp11::mp_reverse; + using boost::mp11::mp_size_t; + using boost::mp11::mp_plus; + + { + int const N = 37; + + using L = mp_iota_c; + + using R1 = mp_reverse_fold, rev_push_front>; + BOOST_TEST_TRAIT_TRUE((std::is_same)); + + using R2 = mp_reverse_fold, rev_push_back>; + BOOST_TEST_TRAIT_TRUE((std::is_same>)); + + using R3 = mp_reverse_fold, mp_plus>; + BOOST_TEST_TRAIT_TRUE((std::is_same>)); + } + return boost::report_errors(); }