mirror of
https://github.com/boostorg/mp11.git
synced 2025-08-02 22:14:26 +02:00
Add a 'from' parameter to mp_iota, mp_iota_c. Refs #78.
This commit is contained in:
@@ -323,9 +323,9 @@ template<template<class T, T... I> class S, class U, U... J, class F> struct mp_
|
||||
|
||||
template<class S, class F = mp_int<0>> using mp_from_sequence = typename detail::mp_from_sequence_impl<S, F>::type;
|
||||
|
||||
// mp_iota(_c)<N>
|
||||
template<std::size_t N> using mp_iota_c = mp_from_sequence<make_index_sequence<N>>;
|
||||
template<class N> using mp_iota = mp_from_sequence<make_integer_sequence<typename std::remove_const<decltype(N::value)>::type, N::value>>;
|
||||
// mp_iota(_c)<N, F>
|
||||
template<std::size_t N, std::size_t F = 0> using mp_iota_c = mp_from_sequence<make_index_sequence<N>, mp_size_t<F>>;
|
||||
template<class N, class F = mp_int<0>> using mp_iota = mp_from_sequence<make_integer_sequence<typename std::remove_const<decltype(N::value)>::type, N::value>, F>;
|
||||
|
||||
// mp_at(_c)<L, I>
|
||||
namespace detail
|
||||
|
@@ -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 : : : <toolset>gcc-4.7:<warnings>all ;
|
||||
run mp_take.cpp ;
|
||||
|
37
test/mp_iota_2.cpp
Normal file
37
test/mp_iota_2.cpp
Normal file
@@ -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 <boost/mp11/algorithm.hpp>
|
||||
#include <boost/mp11/integral.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
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_iota_c<0, 7>, mp_list<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota_c<1, 7>, mp_list<mp_size_t<7>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota_c<2, 7>, mp_list<mp_size_t<7>, mp_size_t<8>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota_c<3, 7>, mp_list<mp_size_t<7>, mp_size_t<8>, mp_size_t<9>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota_c<4, 7>, mp_list<mp_size_t<7>, mp_size_t<8>, mp_size_t<9>, mp_size_t<10>>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_size_t<0>, mp_int<4>>, mp_list<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_size_t<1>, mp_int<4>>, mp_list<mp_size_t<4>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_size_t<2>, mp_int<4>>, mp_list<mp_size_t<4>, mp_size_t<5>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_size_t<3>, mp_int<4>>, mp_list<mp_size_t<4>, mp_size_t<5>, mp_size_t<6>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_size_t<4>, mp_int<4>>, mp_list<mp_size_t<4>, mp_size_t<5>, mp_size_t<6>, mp_size_t<7>>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_int<0>, mp_int<-2>>, mp_list<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_int<1>, mp_int<-2>>, mp_list<mp_int<-2>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_int<2>, mp_int<-2>>, mp_list<mp_int<-2>, mp_int<-1>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_int<3>, mp_int<-2>>, mp_list<mp_int<-2>, mp_int<-1>, mp_int<0>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_int<4>, mp_int<-2>>, mp_list<mp_int<-2>, mp_int<-1>, mp_int<0>, mp_int<+1>>>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user