vecmem 1.14.0
Loading...
Searching...
No Matches
conditional_memory_resource.hpp
1/*
2 * VecMem project, part of the ACTS project (R&D line)
3 *
4 * (c) 2021-2023 CERN for the benefit of the ACTS project
5 *
6 * Mozilla Public License Version 2.0
7 */
8
9#pragma once
10
11// Local include(s).
12#include "vecmem/memory/details/memory_resource_base.hpp"
13#include "vecmem/memory/memory_resource.hpp"
14#include "vecmem/vecmem_core_export.hpp"
15
16// System include(s).
17#include <cstddef>
18#include <functional>
19#include <memory>
20
21namespace vecmem {
22
23// Forward declaration(s).
24namespace details {
25class conditional_memory_resource_impl;
26}
27
37
38public:
48 memory_resource& upstream,
49 std::function<bool(std::size_t, std::size_t)> pred);
55
59
65 delete;
66
67private:
70
73 virtual void* do_allocate(std::size_t, std::size_t) override final;
76 virtual void do_deallocate(void* p, std::size_t,
77 std::size_t) override final;
78
80
82 std::unique_ptr<details::conditional_memory_resource_impl> m_impl;
83
84}; // class conditional_memory_resource
85
86} // namespace vecmem
This memory resource conditionally allocates memory.
Definition conditional_memory_resource.hpp:36
VECMEM_CORE_EXPORT ~conditional_memory_resource()
Destructor.
virtual VECMEM_CORE_EXPORT void do_deallocate(void *p, std::size_t, std::size_t) override final
De-allocate a previously allocated memory block.
VECMEM_CORE_EXPORT conditional_memory_resource(conditional_memory_resource &&parent)
Move constructor.
conditional_memory_resource(const conditional_memory_resource &)=delete
Disallow copying the memory resource.
conditional_memory_resource & operator=(const conditional_memory_resource &)=delete
Disallow copying the memory resource.
VECMEM_CORE_EXPORT conditional_memory_resource & operator=(conditional_memory_resource &&rhs)
Move assignment operator.
virtual VECMEM_CORE_EXPORT void * do_allocate(std::size_t, std::size_t) override final
Allocate memory with one of the underlying resources.
Base class for implementations of the vecmem::memory_resource interface.
Definition memory_resource_base.hpp:25
Main namespace for the vecmem classes/functions.
Definition atomic_ref.hpp:16
std::vector< T, vecmem::polymorphic_allocator< T > > vector
Alias type for vectors with our polymorphic allocator.
Definition vector.hpp:35