| 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_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 |
|
| 20 |
#include <range/v3/iterator/concepts.hpp> |
| 21 |
#include <range/v3/iterator/operations.hpp> |
| 22 |
#include <range/v3/range/access.hpp> |
| 23 |
#include <range/v3/range/concepts.hpp> |
| 24 |
#include <range/v3/range/traits.hpp> |
| 25 |
#include <range/v3/utility/static_const.hpp> |
| 26 |
|
| 27 |
#include <range/v3/detail/prologue.hpp> |
| 28 |
|
| 29 |
namespace ranges |
| 30 |
{ |
| 31 |
/// \addtogroup group-algorithms |
| 32 |
/// @{ |
| 33 |
RANGES_FUNC_BEGIN(fill_n) |
| 34 |
|
| 35 |
/// \brief function template \c equal |
| 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 |
} |
| 54 |
/// @} |
| 55 |
} // namespace ranges |
| 56 |
|
| 57 |
#include <range/v3/detail/epilogue.hpp> |
| 58 |
|
| 59 |
#endif |