WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
new_allocator.hpp
Go to the documentation of this file.
1// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
2// SPDX-License-Identifier: Zlib
3
4#ifndef WPI_MEMORY_NEW_ALLOCATOR_HPP_INCLUDED
5#define WPI_MEMORY_NEW_ALLOCATOR_HPP_INCLUDED
6
7/// \file
8/// Class \ref wpi::memory::new_allocator.
9
11#include "config.hpp"
12
13#if WPI_MEMORY_EXTERN_TEMPLATE
14#include "allocator_traits.hpp"
15#endif
16
17namespace wpi
18{
19 namespace memory
20 {
21 struct allocator_info;
22
23 namespace detail
24 {
26 {
27 static allocator_info info() noexcept;
28
29 static void* allocate(std::size_t size, std::size_t) noexcept;
30
31 static void deallocate(void* ptr, std::size_t size, std::size_t) noexcept;
32
33 static std::size_t max_node_size() noexcept;
34 };
35
37 new_alloator_leak_checker)
38 } // namespace detail
39
40 /// A stateless RawAllocator that allocates memory using (nothrow) <tt>operator new</tt>.
41 /// If the operator returns \c nullptr, it behaves like \c new and loops calling \c std::new_handler,
42 /// but instead of throwing a \c std::bad_alloc exception, it throws \ref out_of_memory.
43 /// \ingroup memory_allocator
45 WPI_IMPL_DEFINED(detail::lowlevel_allocator<detail::new_allocator_impl>);
46
47#if WPI_MEMORY_EXTERN_TEMPLATE
49 extern template class allocator_traits<new_allocator>;
50#endif
51 } // namespace memory
52} // namespace wpi
53
54#endif // WPI_MEMORY_NEW_ALLOCATOR_HPP_INCLUDED
The default specialization of the wpi::memory::allocator_traits.
The default specialization of the allocator_traits for a RawAllocator.
Definition allocator_traits.hpp:292
Definition lowlevel_allocator.hpp:37
Configuration macros.
auto ptr(T p) -> const void *
Converts p to const void* for pointer formatting.
Definition format.h:3821
implementation_defined new_allocator
A stateless RawAllocator that allocates memory using (nothrow) operator new.
Definition new_allocator.hpp:44
#define WPI_MEMORY_LL_ALLOCATOR_LEAK_CHECKER(functor, var_name)
Definition lowlevel_allocator.hpp:79
detail namespace with internal helper functions
Definition input_adapters.h:32
Implement std::hash so that hash_code can be used in STL containers.
Definition PointerIntPair.h:280
Memory namespace.
Definition heap_allocator.hpp:20
Foonathan namespace.
Definition ntcore_cpp.h:26
Contains information about an allocator.
Definition error.hpp:23
Definition new_allocator.hpp:26
static void deallocate(void *ptr, std::size_t size, std::size_t) noexcept
static std::size_t max_node_size() noexcept
static void * allocate(std::size_t size, std::size_t) noexcept
static allocator_info info() noexcept