]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/algorithm/include/boost/algorithm/cxx11/iota.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / algorithm / include / boost / algorithm / cxx11 / iota.hpp
CommitLineData
7c673cae
FG
1/*
2 Copyright (c) Marshall Clow 2008-2012.
3
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)
6*/
7
8/// \file iota.hpp
9/// \brief Generate an increasing series
10/// \author Marshall Clow
11
12#ifndef BOOST_ALGORITHM_IOTA_HPP
13#define BOOST_ALGORITHM_IOTA_HPP
14
15#include <boost/range/begin.hpp>
16#include <boost/range/end.hpp>
17
18namespace boost { namespace algorithm {
19
20/// \fn iota ( ForwardIterator first, ForwardIterator last, T value )
21/// \brief Generates an increasing sequence of values, and stores them in [first, last)
22///
23/// \param first The start of the input sequence
24/// \param last One past the end of the input sequence
25/// \param value The initial value of the sequence to be generated
26/// \note This function is part of the C++2011 standard library.
27template <typename ForwardIterator, typename T>
28void iota ( ForwardIterator first, ForwardIterator last, T value )
29{
30 for ( ; first != last; ++first, ++value )
31 *first = value;
32}
33
34/// \fn iota ( Range &r, T value )
35/// \brief Generates an increasing sequence of values, and stores them in the input Range.
36///
37/// \param r The input range
38/// \param value The initial value of the sequence to be generated
39///
40template <typename Range, typename T>
41void iota ( Range &r, T value )
42{
43 boost::algorithm::iota (boost::begin(r), boost::end(r), value);
44}
45
46
47/// \fn iota_n ( OutputIterator out, T value, std::size_t n )
48/// \brief Generates an increasing sequence of values, and stores them in the input Range.
49///
50/// \param out An output iterator to write the results into
51/// \param value The initial value of the sequence to be generated
52/// \param n The number of items to write
53///
54template <typename OutputIterator, typename T>
55OutputIterator iota_n ( OutputIterator out, T value, std::size_t n )
56{
57 for ( ; n > 0; --n, ++value )
58 *out++ = value;
59
60 return out;
61}
62
63}}
64
65#endif // BOOST_ALGORITHM_IOTA_HPP