1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef _LIBCPP___ALGORITHM_RANGES_FILL_N_H 10 #define _LIBCPP___ALGORITHM_RANGES_FILL_N_H 11 12 #include <__config> 13 #include <__iterator/concepts.h> 14 #include <__iterator/incrementable_traits.h> 15 16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 17 # pragma GCC system_header 18 #endif 19 20 #if _LIBCPP_STD_VER >= 20 21 22 _LIBCPP_BEGIN_NAMESPACE_STD 23 24 namespace ranges { 25 namespace __fill_n { 26 struct __fn { 27 template <class _Type, output_iterator<const _Type&> _Iter> 28 _LIBCPP_HIDE_FROM_ABI constexpr _Iter 29 operator()(_Iter __first, iter_difference_t<_Iter> __n, const _Type& __value) const { 30 for (; __n != 0; --__n) { 31 *__first = __value; 32 ++__first; 33 } 34 return __first; 35 } 36 }; 37 } // namespace __fill_n 38 39 inline namespace __cpo { 40 inline constexpr auto fill_n = __fill_n::__fn{}; 41 } // namespace __cpo 42 } // namespace ranges 43 44 _LIBCPP_END_NAMESPACE_STD 45 46 #endif // _LIBCPP_STD_VER >= 20 47 48 #endif // _LIBCPP___ALGORITHM_RANGES_FILL_N_H 49