Debian Codegraph @

3rd_party/range-v3/range/v3/numeric/iota.hpp

raw
1 /// \file
2 // Range v3 library
3 //
4 // Copyright Eric Niebler 2013-present
5 //
6 // Use, modification and distribution is subject to the
7 // Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10 //
11 // Project home: https://github.com/ericniebler/range-v3
12 //
13 #ifndef RANGES_V3_NUMERIC_IOTA_HPP
14 #define RANGES_V3_NUMERIC_IOTA_HPP
15
16 #include <range/v3/iterator/concepts.hpp>
17 #include <range/v3/range/access.hpp>
18 #include <range/v3/range/concepts.hpp>
19 #include <range/v3/range/dangling.hpp>
20 #include <range/v3/range/traits.hpp>
21 #include <range/v3/utility/static_const.hpp>
22
23 #include <range/v3/detail/prologue.hpp>
24
25 namespace ranges
26 {
27 /// \addtogroup group-numerics
28 /// @{
29 struct iota_fn
30 {
31 template(typename O, typename S, typename T)(
32 requires output_iterator<O, T const &> AND sentinel_for<S, O> AND
33 weakly_incrementable<T>)
34 O operator()(O first, S last, T val) const
35 {
36 for(; first != last; ++first, ++val)
37 *first = detail::as_const(val);
38 return first;
39 }
40
41 template(typename Rng, typename T)(
42 requires output_range<Rng, T const &> AND weakly_incrementable<T>)
43 borrowed_iterator_t<Rng> operator()(Rng && rng, T val) const //
44 {
45 return (*this)(begin(rng), end(rng), detail::move(val));
46 }
47 };
48
49 RANGES_INLINE_VARIABLE(iota_fn, iota)
50 /// @}
51 } // namespace ranges
52
53 #include <range/v3/detail/epilogue.hpp>
54
55 #endif