| 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_HPP |
| 14 |
#define RANGES_V3_ALGORITHM_FILL_HPP |
| 15 |
|
| 16 |
#include <range/v3/range_fwd.hpp> |
| 17 |
|
| 18 |
#include <range/v3/iterator/concepts.hpp> |
| 19 |
#include <range/v3/range/access.hpp> |
| 20 |
#include <range/v3/range/concepts.hpp> |
| 21 |
#include <range/v3/range/dangling.hpp> |
| 22 |
#include <range/v3/range/traits.hpp> |
| 23 |
#include <range/v3/utility/static_const.hpp> |
| 24 |
|
| 25 |
#include <range/v3/detail/prologue.hpp> |
| 26 |
|
| 27 |
namespace ranges |
| 28 |
{ |
| 29 |
/// \addtogroup group-algorithms |
| 30 |
/// @{ |
| 31 |
RANGES_FUNC_BEGIN(fill) |
| 32 |
|
| 33 |
/// \brief function template \c fill |
| 34 |
template(typename O, typename S, typename V)( |
| 35 |
requires output_iterator<O, V const &> AND sentinel_for<S, O>) |
| 36 |
constexpr O RANGES_FUNC(fill)(O first, S last, V const & val) // |
| 37 |
{ |
| 38 |
for(; first != last; ++first) |
| 39 |
*first = val; |
| 40 |
return first; |
| 41 |
} |
| 42 |
|
| 43 |
/// \overload |
| 44 |
template(typename Rng, typename V)( |
| 45 |
requires output_range<Rng, V const &>) |
| 46 |
constexpr borrowed_iterator_t<Rng> RANGES_FUNC(fill)(Rng && rng, V const & val) |
| 47 |
{ |
| 48 |
return (*this)(begin(rng), end(rng), val); |
| 49 |
} |
| 50 |
|
| 51 |
RANGES_FUNC_END(fill) |
| 52 |
|
| 53 |
namespace cpp20 |
| 54 |
{ |
| 55 |
using ranges::fill; |
| 56 |
} |
| 57 |
/// @} |
| 58 |
} // namespace ranges |
| 59 |
|
| 60 |
#include <range/v3/detail/epilogue.hpp> |
| 61 |
|
| 62 |
#endif |