Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:35

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___CXX03___MEMORY_RANGES_CONSTRUCT_AT_H
0011 #define _LIBCPP___CXX03___MEMORY_RANGES_CONSTRUCT_AT_H
0012 
0013 #include <__cxx03/__concepts/destructible.h>
0014 #include <__cxx03/__config>
0015 #include <__cxx03/__iterator/incrementable_traits.h>
0016 #include <__cxx03/__iterator/iterator_traits.h>
0017 #include <__cxx03/__memory/concepts.h>
0018 #include <__cxx03/__memory/construct_at.h>
0019 #include <__cxx03/__ranges/access.h>
0020 #include <__cxx03/__ranges/concepts.h>
0021 #include <__cxx03/__ranges/dangling.h>
0022 #include <__cxx03/__utility/declval.h>
0023 #include <__cxx03/__utility/forward.h>
0024 #include <__cxx03/__utility/move.h>
0025 #include <__cxx03/new>
0026 
0027 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0028 #  pragma GCC system_header
0029 #endif
0030 
0031 _LIBCPP_PUSH_MACROS
0032 #include <__cxx03/__undef_macros>
0033 
0034 _LIBCPP_BEGIN_NAMESPACE_STD
0035 
0036 #if _LIBCPP_STD_VER >= 20
0037 namespace ranges {
0038 
0039 // construct_at
0040 
0041 namespace __construct_at {
0042 
0043 struct __fn {
0044   template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>
0045   _LIBCPP_HIDE_FROM_ABI constexpr _Tp* operator()(_Tp* __location, _Args&&... __args) const {
0046     return std::construct_at(__location, std::forward<_Args>(__args)...);
0047   }
0048 };
0049 
0050 } // namespace __construct_at
0051 
0052 inline namespace __cpo {
0053 inline constexpr auto construct_at = __construct_at::__fn{};
0054 } // namespace __cpo
0055 
0056 // destroy_at
0057 
0058 namespace __destroy_at {
0059 
0060 struct __fn {
0061   template <destructible _Tp>
0062   _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Tp* __location) const noexcept {
0063     std::destroy_at(__location);
0064   }
0065 };
0066 
0067 } // namespace __destroy_at
0068 
0069 inline namespace __cpo {
0070 inline constexpr auto destroy_at = __destroy_at::__fn{};
0071 } // namespace __cpo
0072 
0073 // destroy
0074 
0075 namespace __destroy {
0076 
0077 struct __fn {
0078   template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel>
0079     requires destructible<iter_value_t<_InputIterator>>
0080   _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept {
0081     return std::__destroy(std::move(__first), std::move(__last));
0082   }
0083 
0084   template <__nothrow_input_range _InputRange>
0085     requires destructible<range_value_t<_InputRange>>
0086   _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_InputRange> operator()(_InputRange&& __range) const noexcept {
0087     return (*this)(ranges::begin(__range), ranges::end(__range));
0088   }
0089 };
0090 
0091 } // namespace __destroy
0092 
0093 inline namespace __cpo {
0094 inline constexpr auto destroy = __destroy::__fn{};
0095 } // namespace __cpo
0096 
0097 // destroy_n
0098 
0099 namespace __destroy_n {
0100 
0101 struct __fn {
0102   template <__nothrow_input_iterator _InputIterator>
0103     requires destructible<iter_value_t<_InputIterator>>
0104   _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator
0105   operator()(_InputIterator __first, iter_difference_t<_InputIterator> __n) const noexcept {
0106     return std::destroy_n(std::move(__first), __n);
0107   }
0108 };
0109 
0110 } // namespace __destroy_n
0111 
0112 inline namespace __cpo {
0113 inline constexpr auto destroy_n = __destroy_n::__fn{};
0114 } // namespace __cpo
0115 
0116 } // namespace ranges
0117 
0118 #endif // _LIBCPP_STD_VER >= 20
0119 
0120 _LIBCPP_END_NAMESPACE_STD
0121 
0122 _LIBCPP_POP_MACROS
0123 
0124 #endif // _LIBCPP___CXX03___MEMORY_RANGES_CONSTRUCT_AT_H