181ad6265SDimitry Andric //===----------------------------------------------------------------------===// 281ad6265SDimitry Andric // 381ad6265SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 481ad6265SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 581ad6265SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 681ad6265SDimitry Andric // 781ad6265SDimitry Andric //===----------------------------------------------------------------------===// 881ad6265SDimitry Andric 981ad6265SDimitry Andric #ifndef _LIBCPP___ALGORITHM_RANGES_FILL_H 1081ad6265SDimitry Andric #define _LIBCPP___ALGORITHM_RANGES_FILL_H 1181ad6265SDimitry Andric 1281ad6265SDimitry Andric #include <__algorithm/ranges_fill_n.h> 1381ad6265SDimitry Andric #include <__config> 1481ad6265SDimitry Andric #include <__iterator/concepts.h> 1581ad6265SDimitry Andric #include <__ranges/access.h> 1681ad6265SDimitry Andric #include <__ranges/concepts.h> 1781ad6265SDimitry Andric #include <__ranges/dangling.h> 1881ad6265SDimitry Andric 1981ad6265SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2081ad6265SDimitry Andric # pragma GCC system_header 2181ad6265SDimitry Andric #endif 2281ad6265SDimitry Andric 23*b3edf446SDimitry Andric _LIBCPP_PUSH_MACROS 24*b3edf446SDimitry Andric #include <__undef_macros> 25*b3edf446SDimitry Andric 2606c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 20 2781ad6265SDimitry Andric 2881ad6265SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD 2981ad6265SDimitry Andric 3081ad6265SDimitry Andric namespace ranges { 3181ad6265SDimitry Andric namespace __fill { 3281ad6265SDimitry Andric struct __fn { 3381ad6265SDimitry Andric template <class _Type, output_iterator<const _Type&> _Iter, sentinel_for<_Iter> _Sent> operator__fn3406c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last, const _Type& __value) const { 35fcaf7f86SDimitry Andric if constexpr (random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>) { 3681ad6265SDimitry Andric return ranges::fill_n(__first, __last - __first, __value); 3781ad6265SDimitry Andric } else { 3881ad6265SDimitry Andric for (; __first != __last; ++__first) 3981ad6265SDimitry Andric *__first = __value; 4081ad6265SDimitry Andric return __first; 4181ad6265SDimitry Andric } 4281ad6265SDimitry Andric } 4381ad6265SDimitry Andric 4481ad6265SDimitry Andric template <class _Type, output_range<const _Type&> _Range> operator__fn4506c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> operator()(_Range&& __range, const _Type& __value) const { 4681ad6265SDimitry Andric return (*this)(ranges::begin(__range), ranges::end(__range), __value); 4781ad6265SDimitry Andric } 4881ad6265SDimitry Andric }; 4981ad6265SDimitry Andric } // namespace __fill 5081ad6265SDimitry Andric 5181ad6265SDimitry Andric inline namespace __cpo { 5281ad6265SDimitry Andric inline constexpr auto fill = __fill::__fn{}; 5381ad6265SDimitry Andric } // namespace __cpo 5481ad6265SDimitry Andric } // namespace ranges 5581ad6265SDimitry Andric 5681ad6265SDimitry Andric _LIBCPP_END_NAMESPACE_STD 5781ad6265SDimitry Andric 5806c3fb27SDimitry Andric #endif // _LIBCPP_STD_VER >= 20 5981ad6265SDimitry Andric 60*b3edf446SDimitry Andric _LIBCPP_POP_MACROS 61*b3edf446SDimitry Andric 6281ad6265SDimitry Andric #endif // _LIBCPP___ALGORITHM_RANGES_FILL_H 63