Warning: This file is not a C or C++ file. It does not have highlighting.
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-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H |
10 | #define _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H |
11 | |
12 | #include <__config> |
13 | #include <__cstddef/size_t.h> |
14 | #include <__memory/allocator_traits.h> |
15 | |
16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
17 | # pragma GCC system_header |
18 | #endif |
19 | |
20 | _LIBCPP_BEGIN_NAMESPACE_STD |
21 | |
22 | #if _LIBCPP_STD_VER >= 23 |
23 | |
24 | template <class _Alloc> |
25 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto __allocate_at_least(_Alloc& __alloc, size_t __n) { |
26 | return std::allocator_traits<_Alloc>::allocate_at_least(__alloc, __n); |
27 | } |
28 | |
29 | #else |
30 | |
31 | template <class _Pointer> |
32 | struct __allocation_result { |
33 | _Pointer ptr; |
34 | size_t count; |
35 | }; |
36 | |
37 | template <class _Alloc> |
38 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI |
39 | _LIBCPP_CONSTEXPR __allocation_result<typename allocator_traits<_Alloc>::pointer> |
40 | __allocate_at_least(_Alloc& __alloc, size_t __n) { |
41 | return {__alloc.allocate(__n), __n}; |
42 | } |
43 | |
44 | #endif // _LIBCPP_STD_VER >= 23 |
45 | |
46 | _LIBCPP_END_NAMESPACE_STD |
47 | |
48 | #endif // _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H |
49 |
Warning: This file is not a C or C++ file. It does not have highlighting.