From 99070f7f5c92a7ffea03bf72804f971f52562015 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 14 May 2023 03:49:28 +0300 Subject: [PATCH] Add a 'from' parameter to mp_iota, mp_iota_c. Refs #78. --- include/boost/mp11/algorithm.hpp | 6 +++--- test/Jamfile | 1 + test/mp_iota_2.cpp | 37 ++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 test/mp_iota_2.cpp diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index d931457..b5508e6 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -323,9 +323,9 @@ template class S, class U, U... J, class F> struct mp_ template> using mp_from_sequence = typename detail::mp_from_sequence_impl::type; -// mp_iota(_c) -template using mp_iota_c = mp_from_sequence>; -template using mp_iota = mp_from_sequence::type, N::value>>; +// mp_iota(_c) +template using mp_iota_c = mp_from_sequence, mp_size_t>; +template> using mp_iota = mp_from_sequence::type, N::value>, F>; // mp_at(_c) namespace detail diff --git a/test/Jamfile b/test/Jamfile index 661b801..4a308a8 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -68,6 +68,7 @@ run mp_repeat.cpp ; run mp_product.cpp ; run mp_drop.cpp ; run mp_iota.cpp ; +run mp_iota_2.cpp ; run mp_at.cpp ; run mp_at_sf.cpp : : : gcc-4.7:all ; run mp_take.cpp ; diff --git a/test/mp_iota_2.cpp b/test/mp_iota_2.cpp new file mode 100644 index 0000000..f1a0f07 --- /dev/null +++ b/test/mp_iota_2.cpp @@ -0,0 +1,37 @@ +// Copyright 2015, 2023 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_iota; + using boost::mp11::mp_iota_c; + using boost::mp11::mp_int; + using boost::mp11::mp_size_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list, mp_size_t<8>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list, mp_size_t<8>, mp_size_t<9>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list, mp_size_t<8>, mp_size_t<9>, mp_size_t<10>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_int<4>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_int<4>>, mp_list>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_int<4>>, mp_list, mp_size_t<5>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_int<4>>, mp_list, mp_size_t<5>, mp_size_t<6>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_int<4>>, mp_list, mp_size_t<5>, mp_size_t<6>, mp_size_t<7>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_int<-2>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_int<-2>>, mp_list>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_int<-2>>, mp_list, mp_int<-1>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_int<-2>>, mp_list, mp_int<-1>, mp_int<0>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_int<-2>>, mp_list, mp_int<-1>, mp_int<0>, mp_int<+1>>>)); + + return boost::report_errors(); +}