brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · bf53dd8 Raw
66 lines · c
1// -*- C++ -*-2//===----------------------------------------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP___NUMERIC_RANGES_IOTA_H11#define _LIBCPP___NUMERIC_RANGES_IOTA_H12 13#include <__algorithm/out_value_result.h>14#include <__config>15#include <__iterator/concepts.h>16#include <__ranges/access.h>17#include <__ranges/concepts.h>18#include <__ranges/dangling.h>19#include <__utility/as_const.h>20#include <__utility/move.h>21 22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#  pragma GCC system_header24#endif25 26_LIBCPP_PUSH_MACROS27#include <__undef_macros>28 29_LIBCPP_BEGIN_NAMESPACE_STD30 31#if _LIBCPP_STD_VER >= 2332namespace ranges {33template <typename _Out, typename _Tp>34using iota_result = ranges::out_value_result<_Out, _Tp>;35 36struct __iota_fn {37public:38  template <input_or_output_iterator _Out, sentinel_for<_Out> _Sent, weakly_incrementable _Tp>39    requires indirectly_writable<_Out, const _Tp&>40  _LIBCPP_HIDE_FROM_ABI static constexpr iota_result<_Out, _Tp> operator()(_Out __first, _Sent __last, _Tp __value) {41    while (__first != __last) {42      *__first = std::as_const(__value);43      ++__first;44      ++__value;45    }46    return {std::move(__first), std::move(__value)};47  }48 49  template <weakly_incrementable _Tp, ranges::output_range<const _Tp&> _Range>50  _LIBCPP_HIDE_FROM_ABI static constexpr iota_result<ranges::borrowed_iterator_t<_Range>, _Tp>51  operator()(_Range&& __r, _Tp __value) {52    return operator()(ranges::begin(__r), ranges::end(__r), std::move(__value));53  }54};55 56inline constexpr auto iota = __iota_fn{};57} // namespace ranges58 59#endif // _LIBCPP_STD_VER >= 2360 61_LIBCPP_END_NAMESPACE_STD62 63_LIBCPP_POP_MACROS64 65#endif // _LIBCPP___NUMERIC_RANGES_IOTA_H66