Warning: This file is not a C or C++ file. It does not have highlighting.
| 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-exception |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP___MEMORY_RANGES_CONSTRUCT_AT_H |
| 11 | #define _LIBCPP___MEMORY_RANGES_CONSTRUCT_AT_H |
| 12 | |
| 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/construct_at.h> |
| 19 | #include <__ranges/access.h> |
| 20 | #include <__ranges/concepts.h> |
| 21 | #include <__ranges/dangling.h> |
| 22 | #include <__utility/declval.h> |
| 23 | #include <__utility/forward.h> |
| 24 | #include <__utility/move.h> |
| 25 | |
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 27 | # pragma GCC system_header |
| 28 | #endif |
| 29 | |
| 30 | _LIBCPP_PUSH_MACROS |
| 31 | #include <__undef_macros> |
| 32 | |
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | |
| 35 | #if _LIBCPP_STD_VER >= 20 |
| 36 | namespace ranges { |
| 37 | |
| 38 | // construct_at |
| 39 | |
| 40 | struct __construct_at { |
| 41 | template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))> |
| 42 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp* operator()(_Tp* __location, _Args&&... __args) const { |
| 43 | return std::construct_at(__location, std::forward<_Args>(__args)...); |
| 44 | } |
| 45 | }; |
| 46 | |
| 47 | inline namespace __cpo { |
| 48 | inline constexpr auto construct_at = __construct_at{}; |
| 49 | } // namespace __cpo |
| 50 | |
| 51 | // destroy_at |
| 52 | |
| 53 | struct __destroy_at { |
| 54 | template <destructible _Tp> |
| 55 | _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Tp* __location) const noexcept { |
| 56 | std::destroy_at(__location); |
| 57 | } |
| 58 | }; |
| 59 | |
| 60 | inline namespace __cpo { |
| 61 | inline constexpr auto destroy_at = __destroy_at{}; |
| 62 | } // namespace __cpo |
| 63 | |
| 64 | } // namespace ranges |
| 65 | |
| 66 | #endif // _LIBCPP_STD_VER >= 20 |
| 67 | |
| 68 | _LIBCPP_END_NAMESPACE_STD |
| 69 | |
| 70 | _LIBCPP_POP_MACROS |
| 71 | |
| 72 | #endif // _LIBCPP___MEMORY_RANGES_CONSTRUCT_AT_H |
| 73 |
Warning: This file is not a C or C++ file. It does not have highlighting.
