Path: blob/main/contrib/llvm-project/libcxx/include/__memory/ranges_destroy.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___MEMORY_RANGES_DESTROY_H10#define _LIBCPP___MEMORY_RANGES_DESTROY_H1112#include <__concepts/destructible.h>13#include <__config>14#include <__iterator/incrementable_traits.h>15#include <__iterator/iterator_traits.h>16#include <__memory/concepts.h>17#include <__memory/destroy.h>18#include <__ranges/access.h>19#include <__ranges/concepts.h>20#include <__ranges/dangling.h>21#include <__utility/move.h>2223#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24# pragma GCC system_header25#endif2627_LIBCPP_PUSH_MACROS28#include <__undef_macros>2930_LIBCPP_BEGIN_NAMESPACE_STD3132#if _LIBCPP_STD_VER >= 2033namespace ranges {3435// destroy3637struct __destroy {38template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel>39requires destructible<iter_value_t<_InputIterator>>40_LIBCPP_HIDE_FROM_ABI constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept {41return std::__destroy(std::move(__first), std::move(__last));42}4344template <__nothrow_input_range _InputRange>45requires destructible<range_value_t<_InputRange>>46_LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_InputRange> operator()(_InputRange&& __range) const noexcept {47return (*this)(ranges::begin(__range), ranges::end(__range));48}49};5051inline namespace __cpo {52inline constexpr auto destroy = __destroy{};53} // namespace __cpo5455// destroy_n5657struct __destroy_n {58template <__nothrow_input_iterator _InputIterator>59requires destructible<iter_value_t<_InputIterator>>60_LIBCPP_HIDE_FROM_ABI constexpr _InputIterator61operator()(_InputIterator __first, iter_difference_t<_InputIterator> __n) const noexcept {62return std::destroy_n(std::move(__first), __n);63}64};6566inline namespace __cpo {67inline constexpr auto destroy_n = __destroy_n{};68} // namespace __cpo6970} // namespace ranges7172#endif // _LIBCPP_STD_VER >= 207374_LIBCPP_END_NAMESPACE_STD7576_LIBCPP_POP_MACROS7778#endif // _LIBCPP___MEMORY_RANGES_DESTROY_H798081