File indexing completed on 2026-05-03 08:13:56
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___MEMORY_RANGES_CONSTRUCT_AT_H
0011 #define _LIBCPP___MEMORY_RANGES_CONSTRUCT_AT_H
0012
0013 #include <__concepts/destructible.h>
0014 #include <__config>
0015 #include <__iterator/incrementable_traits.h>
0016 #include <__iterator/iterator_traits.h>
0017 #include <__memory/concepts.h>
0018 #include <__memory/construct_at.h>
0019 #include <__ranges/access.h>
0020 #include <__ranges/concepts.h>
0021 #include <__ranges/dangling.h>
0022 #include <__utility/declval.h>
0023 #include <__utility/forward.h>
0024 #include <__utility/move.h>
0025
0026 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0027 # pragma GCC system_header
0028 #endif
0029
0030 _LIBCPP_PUSH_MACROS
0031 #include <__undef_macros>
0032
0033 _LIBCPP_BEGIN_NAMESPACE_STD
0034
0035 #if _LIBCPP_STD_VER >= 20
0036 namespace ranges {
0037
0038
0039
0040 struct __construct_at {
0041 template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>
0042 _LIBCPP_HIDE_FROM_ABI constexpr _Tp* operator()(_Tp* __location, _Args&&... __args) const {
0043 return std::construct_at(__location, std::forward<_Args>(__args)...);
0044 }
0045 };
0046
0047 inline namespace __cpo {
0048 inline constexpr auto construct_at = __construct_at{};
0049 }
0050
0051
0052
0053 struct __destroy_at {
0054 template <destructible _Tp>
0055 _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Tp* __location) const noexcept {
0056 std::destroy_at(__location);
0057 }
0058 };
0059
0060 inline namespace __cpo {
0061 inline constexpr auto destroy_at = __destroy_at{};
0062 }
0063
0064
0065
0066 struct __destroy {
0067 template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel>
0068 requires destructible<iter_value_t<_InputIterator>>
0069 _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept {
0070 return std::__destroy(std::move(__first), std::move(__last));
0071 }
0072
0073 template <__nothrow_input_range _InputRange>
0074 requires destructible<range_value_t<_InputRange>>
0075 _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_InputRange> operator()(_InputRange&& __range) const noexcept {
0076 return (*this)(ranges::begin(__range), ranges::end(__range));
0077 }
0078 };
0079
0080 inline namespace __cpo {
0081 inline constexpr auto destroy = __destroy{};
0082 }
0083
0084
0085
0086 struct __destroy_n {
0087 template <__nothrow_input_iterator _InputIterator>
0088 requires destructible<iter_value_t<_InputIterator>>
0089 _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator
0090 operator()(_InputIterator __first, iter_difference_t<_InputIterator> __n) const noexcept {
0091 return std::destroy_n(std::move(__first), __n);
0092 }
0093 };
0094
0095 inline namespace __cpo {
0096 inline constexpr auto destroy_n = __destroy_n{};
0097 }
0098
0099 }
0100
0101 #endif
0102
0103 _LIBCPP_END_NAMESPACE_STD
0104
0105 _LIBCPP_POP_MACROS
0106
0107 #endif