1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H
10 #define _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H
13 #include <__cstddef/size_t.h>
14 #include <__memory/allocator_traits.h>
16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17 # pragma GCC system_header
20 _LIBCPP_BEGIN_NAMESPACE_STD
22 #if _LIBCPP_STD_VER >= 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
);
31 template <class _Pointer
>
32 struct __allocation_result
{
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
};
44 #endif // _LIBCPP_STD_VER >= 23
46 _LIBCPP_END_NAMESPACE_STD
48 #endif // _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H