brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · f134f14 Raw
80 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___MEMORY_RANGES_DESTROY_H11#define _LIBCPP___MEMORY_RANGES_DESTROY_H12 13#include <__concepts/destructible.h>14#include <__config>15#include <__iterator/incrementable_traits.h>16#include <__iterator/iterator_traits.h>17#include <__memory/concepts.h>18#include <__memory/destroy.h>19#include <__ranges/access.h>20#include <__ranges/concepts.h>21#include <__ranges/dangling.h>22#include <__utility/move.h>23 24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#  pragma GCC system_header26#endif27 28_LIBCPP_PUSH_MACROS29#include <__undef_macros>30 31_LIBCPP_BEGIN_NAMESPACE_STD32 33#if _LIBCPP_STD_VER >= 2034namespace ranges {35 36// destroy37 38struct __destroy {39  template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel>40    requires destructible<iter_value_t<_InputIterator>>41  _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept {42    return std::__destroy(std::move(__first), std::move(__last));43  }44 45  template <__nothrow_input_range _InputRange>46    requires destructible<range_value_t<_InputRange>>47  _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_InputRange> operator()(_InputRange&& __range) const noexcept {48    return (*this)(ranges::begin(__range), ranges::end(__range));49  }50};51 52inline namespace __cpo {53inline constexpr auto destroy = __destroy{};54} // namespace __cpo55 56// destroy_n57 58struct __destroy_n {59  template <__nothrow_input_iterator _InputIterator>60    requires destructible<iter_value_t<_InputIterator>>61  _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator62  operator()(_InputIterator __first, iter_difference_t<_InputIterator> __n) const noexcept {63    return std::destroy_n(std::move(__first), __n);64  }65};66 67inline namespace __cpo {68inline constexpr auto destroy_n = __destroy_n{};69} // namespace __cpo70 71} // namespace ranges72 73#endif // _LIBCPP_STD_VER >= 2074 75_LIBCPP_END_NAMESPACE_STD76 77_LIBCPP_POP_MACROS78 79#endif // _LIBCPP___MEMORY_RANGES_DESTROY_H80