Files
cppdraft_translate/cppdraft/alg/fill.md
2025-10-25 03:02:53 +03:00

5.0 KiB

[alg.fill]

26 Algorithms library [algorithms]

26.7 Mutating sequence operations [alg.modifying.operations]

26.7.6 Fill [alg.fill]

🔗

`template<class ForwardIterator, class T = iterator_traits::value_type> constexpr void fill(ForwardIterator first, ForwardIterator last, const T& value); template<class ExecutionPolicy, class ForwardIterator, class T = iterator_traits::value_type> void fill(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, const T& value);

template<class OutputIterator, class Size, class T = iterator_traits::value_type> constexpr OutputIterator fill_n(OutputIterator first, Size n, const T& value); template<class ExecutionPolicy, class ForwardIterator, class Size, class T = iterator_traits::value_type> ForwardIterator fill_n(ExecutionPolicy&& exec, ForwardIterator first, Size n, const T& value);

template<class O, sentinel_for S, class T = iter_value_t> requires output_iterator<O, const T&> constexpr O ranges::fill(O first, S last, const T& value); template<class R, class T = range_value_t> requires output_range<R, const T&> constexpr borrowed_iterator_t ranges::fill(R&& r, const T& value); template<class O, class T = iter_value_t> requires output_iterator<O, const T&> constexpr O ranges::fill_n(O first, iter_difference_t n, const T& value);

template<execution-policy Ep, random_access_iterator O, sized_sentinel_for S, class T = iter_value_t> requires indirectly_writable<O, const T&> O ranges::fill(Ep&& exec, O first, S last, const T& value); template<execution-policy Ep, sized-random-access-range R, class T = range_value_t> requires indirectly_writable<iterator_t, const T&> borrowed_iterator_t fill(Ep&& exec, R&& r, const T& value); template<execution-policy Ep, random_access_iterator O, class T = iter_value_t> requires indirectly_writable<O, const T&> O ranges::fill_n(Ep&& exec, O first, iter_difference_t n, const T& value); `

1

#

Let N be max(0, n) for the fill_n algorithms, andlast - first for the fill algorithms.

2

#

Mandates: The expression value is writable ([iterator.requirements.general]) to the output iterator.

The type Size is convertible to an integral type ([conv.integral], [class.conv]).

3

#

Effects: Assigns value through all the iterators in the range [first, first + N).

4

#

Returns: first + N.

5

#

Complexity: Exactly N assignments.