Path: blob/main/contrib/llvm-project/libcxx/include/__numeric/ranges_iota.h
213766 views
// -*- C++ -*-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-exception6//7//===----------------------------------------------------------------------===//89#ifndef _LIBCPP___NUMERIC_RANGES_IOTA_H10#define _LIBCPP___NUMERIC_RANGES_IOTA_H1112#include <__algorithm/out_value_result.h>13#include <__config>14#include <__iterator/concepts.h>15#include <__ranges/access.h>16#include <__ranges/concepts.h>17#include <__ranges/dangling.h>18#include <__utility/as_const.h>19#include <__utility/move.h>2021#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22# pragma GCC system_header23#endif2425_LIBCPP_PUSH_MACROS26#include <__undef_macros>2728_LIBCPP_BEGIN_NAMESPACE_STD2930#if _LIBCPP_STD_VER >= 2331namespace ranges {32template <typename _Out, typename _Tp>33using iota_result = ranges::out_value_result<_Out, _Tp>;3435struct __iota_fn {36public:37template <input_or_output_iterator _Out, sentinel_for<_Out> _Sent, weakly_incrementable _Tp>38requires indirectly_writable<_Out, const _Tp&>39_LIBCPP_HIDE_FROM_ABI static constexpr iota_result<_Out, _Tp> operator()(_Out __first, _Sent __last, _Tp __value) {40while (__first != __last) {41*__first = std::as_const(__value);42++__first;43++__value;44}45return {std::move(__first), std::move(__value)};46}4748template <weakly_incrementable _Tp, ranges::output_range<const _Tp&> _Range>49_LIBCPP_HIDE_FROM_ABI static constexpr iota_result<ranges::borrowed_iterator_t<_Range>, _Tp>50operator()(_Range&& __r, _Tp __value) {51return operator()(ranges::begin(__r), ranges::end(__r), std::move(__value));52}53};5455inline constexpr auto iota = __iota_fn{};56} // namespace ranges5758#endif // _LIBCPP_STD_VER >= 235960_LIBCPP_END_NAMESPACE_STD6162_LIBCPP_POP_MACROS6364#endif // _LIBCPP___NUMERIC_RANGES_IOTA_H656667