Horizon
fill_n.hpp
Go to the documentation of this file.
1 // 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_ALGORITHM_FILL_N_HPP
14 #define RANGES_V3_ALGORITHM_FILL_N_HPP
15 
16 #include <utility>
17 
18 #include <range/v3/range_fwd.hpp>
19 
25 #include <range/v3/utility/static_const.hpp>
26 
27 #include <range/v3/detail/prologue.hpp>
28 
29 namespace ranges
30 {
33  RANGES_FUNC_BEGIN(fill_n)
34 
35 
36  template(typename O, typename V)(
37  requires output_iterator<O, V const &>)
38  constexpr O RANGES_FUNC(fill_n)(O first, iter_difference_t<O> n, V const & val)
39  {
40  RANGES_EXPECT(n >= 0);
41  auto norig = n;
42  auto b = uncounted(first);
43  for(; n != 0; ++b, --n)
44  *b = val;
45  return recounted(first, b, norig);
46  }
47 
48  RANGES_FUNC_END(fill_n)
49 
50  namespace cpp20
51  {
52  using ranges::fill_n;
53  }
55 } // namespace ranges
56 
57 #include <range/v3/detail/epilogue.hpp>
58 
59 #endif
template(typename O, typename V)(requires output_iterator< O
function template equal
CPP_concept output_iterator
\concept output_iterator
Definition: concepts.hpp:347
front< Pair > first
Retrieve the first element of the pair Pair.
Definition: meta.hpp:2251