2 Copyright (c) Marshall Clow 2008-2012.
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 /// \brief Generate an increasing series
10 /// \author Marshall Clow
12 #ifndef BOOST_ALGORITHM_IOTA_HPP
13 #define BOOST_ALGORITHM_IOTA_HPP
15 #include <boost/config.hpp>
16 #include <boost/range/begin.hpp>
17 #include <boost/range/end.hpp>
19 namespace boost { namespace algorithm {
21 /// \fn iota ( ForwardIterator first, ForwardIterator last, T value )
22 /// \brief Generates an increasing sequence of values, and stores them in [first, last)
24 /// \param first The start of the input sequence
25 /// \param last One past the end of the input sequence
26 /// \param value The initial value of the sequence to be generated
27 /// \note This function is part of the C++2011 standard library.
28 template <typename ForwardIterator, typename T>
29 BOOST_CXX14_CONSTEXPR void iota ( ForwardIterator first, ForwardIterator last, T value )
31 for ( ; first != last; ++first, ++value )
35 /// \fn iota ( Range &r, T value )
36 /// \brief Generates an increasing sequence of values, and stores them in the input Range.
38 /// \param r The input range
39 /// \param value The initial value of the sequence to be generated
41 template <typename Range, typename T>
42 BOOST_CXX14_CONSTEXPR void iota ( Range &r, T value )
44 boost::algorithm::iota (boost::begin(r), boost::end(r), value);
48 /// \fn iota_n ( OutputIterator out, T value, std::size_t n )
49 /// \brief Generates an increasing sequence of values, and stores them in the input Range.
51 /// \param out An output iterator to write the results into
52 /// \param value The initial value of the sequence to be generated
53 /// \param n The number of items to write
55 template <typename OutputIterator, typename T>
56 BOOST_CXX14_CONSTEXPR OutputIterator iota_n ( OutputIterator out, T value, std::size_t n )
58 for ( ; n > 0; --n, ++value )
66 #endif // BOOST_ALGORITHM_IOTA_HPP