diff --git a/include/boost/mp11/detail/mp_fold.hpp b/include/boost/mp11/detail/mp_fold.hpp index 266d9c1..e2c464c 100644 --- a/include/boost/mp11/detail/mp_fold.hpp +++ b/include/boost/mp11/detail/mp_fold.hpp @@ -10,6 +10,8 @@ #include #include +#include +#include namespace boost { @@ -155,7 +157,7 @@ struct mp_fold_impl, V, F> } // namespace detail -template class F> using mp_fold = typename detail::mp_fold_impl::type; +template class F> using mp_fold = typename detail::mp_fold_impl, V, F>::type; template using mp_fold_q = mp_fold; } // namespace mp11 diff --git a/test/Jamfile b/test/Jamfile index 5d5c94c..538e66a 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -143,9 +143,13 @@ run mp_with_index_cx.cpp ; run mp_from_sequence.cpp ; run mp_from_sequence_2.cpp ; run mp_min_element.cpp ; +run mp_min_element_2.cpp ; run mp_min_element_q.cpp ; +run mp_min_element_q_2.cpp ; run mp_max_element.cpp ; +run mp_max_element_2.cpp ; run mp_max_element_q.cpp ; +run mp_max_element_q_2.cpp ; run mp_nth_element.cpp ; run mp_nth_element_q.cpp ; run mp_back.cpp ; diff --git a/test/mp_max_element_2.cpp b/test/mp_max_element_2.cpp new file mode 100644 index 0000000..966a698 --- /dev/null +++ b/test/mp_max_element_2.cpp @@ -0,0 +1,58 @@ +// Copyright 2017, 2023 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include + +#if !defined(BOOST_MP11_HAS_TEMPLATE_AUTO) + +#pragma message("Test skipped because BOOST_MP11_HAS_TEMPLATE_AUTO is not defined") +int main() {} + +#else + +#include + +template struct V1 {}; +template struct V2 {}; + +int main() +{ + using boost::mp11::mp_max_element; + using boost::mp11::mp_less; + using boost::mp11::mp_int; + + { + using L1 = V1<1>; + BOOST_TEST_TRAIT_SAME(mp_max_element, mp_int<1>); + + using L2 = V1<2, 4, 3, 1>; + BOOST_TEST_TRAIT_SAME(mp_max_element, mp_int<4>); + + using L3 = V1<2, 1, 2, 3>; + BOOST_TEST_TRAIT_SAME(mp_max_element, mp_int<3>); + + using L4 = V1<-1, 1u, -2, 2u>; + BOOST_TEST_TRAIT_SAME(mp_max_element, std::integral_constant); + } + + { + using L1 = V2<1>; + BOOST_TEST_TRAIT_SAME(mp_max_element, mp_int<1>); + + using L2 = V2<2, 4, 3, 1>; + BOOST_TEST_TRAIT_SAME(mp_max_element, mp_int<4>); + + using L3 = V2<2, 1, 2, 3>; + BOOST_TEST_TRAIT_SAME(mp_max_element, mp_int<3>); + + using L4 = V2<-1, 1, -2, 2>; + BOOST_TEST_TRAIT_SAME(mp_max_element, mp_int<2>); + } + + return boost::report_errors(); +} + +#endif diff --git a/test/mp_max_element_q_2.cpp b/test/mp_max_element_q_2.cpp new file mode 100644 index 0000000..4956d8a --- /dev/null +++ b/test/mp_max_element_q_2.cpp @@ -0,0 +1,61 @@ +// Copyright 2017, 2023 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include + +#if !defined(BOOST_MP11_HAS_TEMPLATE_AUTO) + +#pragma message("Test skipped because BOOST_MP11_HAS_TEMPLATE_AUTO is not defined") +int main() {} + +#else + +#include + +template struct V1 {}; +template struct V2 {}; + +int main() +{ + using boost::mp11::mp_max_element_q; + using boost::mp11::mp_less; + using boost::mp11::mp_int; + using boost::mp11::mp_quote; + + using Q = mp_quote; + + { + using L1 = V1<1>; + BOOST_TEST_TRAIT_SAME(mp_max_element_q, mp_int<1>); + + using L2 = V1<2, 4, 3, 1>; + BOOST_TEST_TRAIT_SAME(mp_max_element_q, mp_int<4>); + + using L3 = V1<2, 1, 2, 3>; + BOOST_TEST_TRAIT_SAME(mp_max_element_q, mp_int<3>); + + using L4 = V1<-1, 1u, -2, 2u>; + BOOST_TEST_TRAIT_SAME(mp_max_element_q, std::integral_constant); + } + + { + using L1 = V2<1>; + BOOST_TEST_TRAIT_SAME(mp_max_element_q, mp_int<1>); + + using L2 = V2<2, 4, 3, 1>; + BOOST_TEST_TRAIT_SAME(mp_max_element_q, mp_int<4>); + + using L3 = V2<2, 1, 2, 3>; + BOOST_TEST_TRAIT_SAME(mp_max_element_q, mp_int<3>); + + using L4 = V2<-1, 1, -2, 2>; + BOOST_TEST_TRAIT_SAME(mp_max_element_q, mp_int<2>); + } + + return boost::report_errors(); +} + +#endif diff --git a/test/mp_min_element_2.cpp b/test/mp_min_element_2.cpp new file mode 100644 index 0000000..8089964 --- /dev/null +++ b/test/mp_min_element_2.cpp @@ -0,0 +1,58 @@ +// Copyright 2017, 2023 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include + +#if !defined(BOOST_MP11_HAS_TEMPLATE_AUTO) + +#pragma message("Test skipped because BOOST_MP11_HAS_TEMPLATE_AUTO is not defined") +int main() {} + +#else + +#include + +template struct V1 {}; +template struct V2 {}; + +int main() +{ + using boost::mp11::mp_min_element; + using boost::mp11::mp_less; + using boost::mp11::mp_int; + + { + using L1 = V1<1>; + BOOST_TEST_TRAIT_SAME(mp_min_element, mp_int<1>); + + using L2 = V1<2, 4, 3, 1>; + BOOST_TEST_TRAIT_SAME(mp_min_element, mp_int<1>); + + using L3 = V1<2, 1, 2, 3>; + BOOST_TEST_TRAIT_SAME(mp_min_element, mp_int<1>); + + using L4 = V1<-1, 1u, -2, 2u>; + BOOST_TEST_TRAIT_SAME(mp_min_element, mp_int<-2>); + } + + { + using L1 = V2<1>; + BOOST_TEST_TRAIT_SAME(mp_min_element, mp_int<1>); + + using L2 = V2<2, 4, 3, 1>; + BOOST_TEST_TRAIT_SAME(mp_min_element, mp_int<1>); + + using L3 = V2<2, 1, 2, 3>; + BOOST_TEST_TRAIT_SAME(mp_min_element, mp_int<1>); + + using L4 = V2<-1, 1, -2, 2>; + BOOST_TEST_TRAIT_SAME(mp_min_element, mp_int<-2>); + } + + return boost::report_errors(); +} + +#endif diff --git a/test/mp_min_element_q_2.cpp b/test/mp_min_element_q_2.cpp new file mode 100644 index 0000000..c1bb920 --- /dev/null +++ b/test/mp_min_element_q_2.cpp @@ -0,0 +1,61 @@ +// Copyright 2017, 2023 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include + +#if !defined(BOOST_MP11_HAS_TEMPLATE_AUTO) + +#pragma message("Test skipped because BOOST_MP11_HAS_TEMPLATE_AUTO is not defined") +int main() {} + +#else + +#include + +template struct V1 {}; +template struct V2 {}; + +int main() +{ + using boost::mp11::mp_min_element_q; + using boost::mp11::mp_less; + using boost::mp11::mp_int; + using boost::mp11::mp_quote; + + using Q = mp_quote; + + { + using L1 = V1<1>; + BOOST_TEST_TRAIT_SAME(mp_min_element_q, mp_int<1>); + + using L2 = V1<2, 4, 3, 1>; + BOOST_TEST_TRAIT_SAME(mp_min_element_q, mp_int<1>); + + using L3 = V1<2, 1, 2, 3>; + BOOST_TEST_TRAIT_SAME(mp_min_element_q, mp_int<1>); + + using L4 = V1<-1, 1u, -2, 2u>; + BOOST_TEST_TRAIT_SAME(mp_min_element_q, mp_int<-2>); + } + + { + using L1 = V2<1>; + BOOST_TEST_TRAIT_SAME(mp_min_element_q, mp_int<1>); + + using L2 = V2<2, 4, 3, 1>; + BOOST_TEST_TRAIT_SAME(mp_min_element_q, mp_int<1>); + + using L3 = V2<2, 1, 2, 3>; + BOOST_TEST_TRAIT_SAME(mp_min_element_q, mp_int<1>); + + using L4 = V2<-1, 1, -2, 2>; + BOOST_TEST_TRAIT_SAME(mp_min_element_q, mp_int<-2>); + } + + return boost::report_errors(); +} + +#endif