Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / include / __memory / allocate_at_least.h
blob9b5a8bcbd4596b770975d35542c398e3166c6b25
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 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H
10 #define _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H
12 #include <__config>
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
18 #endif
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);
29 #else
31 template <class _Pointer>
32 struct __allocation_result {
33 _Pointer ptr;
34 size_t count;
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