vecmem 1.14.0
Loading...
Searching...
No Matches
vector_buffer.ipp
1/* VecMem project, part of the ACTS project (R&D line)
2 *
3 * (c) 2021-2024 CERN for the benefit of the ACTS project
4 *
5 * Mozilla Public License Version 2.0
6 */
7#pragma once
8
9// vecmem include(s).
10#include "vecmem/containers/details/aligned_multiple_placement.hpp"
11
12// System include(s).
13#include <cassert>
14#include <memory>
15
16namespace vecmem {
17namespace data {
18
23template <typename TYPE>
26
27template <typename TYPE>
29 memory_resource& resource, buffer_type type)
30 : base_type(capacity, nullptr, nullptr) {
31
32 // Exit early for null-capacity buffers.
33 if (capacity == 0) {
34 return;
35 }
36
37 // Allocate the memory of the buffer.
38 size_pointer size = nullptr;
39 pointer ptr = nullptr;
40 std::tie(m_memory, size, ptr) =
41 details::aligned_multiple_placement<std::remove_pointer_t<size_pointer>,
42 std::remove_pointer_t<pointer>>(
43 resource, type == buffer_type::fixed_size ? 0 : 1, capacity);
44
45 // Set up the base object.
47}
48
49} // namespace data
50
51template <typename TYPE>
56
57template <typename TYPE>
59
60 return data;
61}
62
63} // namespace vecmem
Object owning the data held by it.
Definition vector_buffer.hpp:29
vector_buffer()
Make sure that the template type does not have a custom destructor.
Definition vector_buffer.ipp:24
typename base_type::pointer pointer
Pointer type definition coming from the base class.
Definition vector_buffer.hpp:39
typename base_type::size_type size_type
Size type definition coming from the base class.
Definition vector_buffer.hpp:35
typename base_type::size_pointer size_pointer
Size pointer type definition coming from the base class.
Definition vector_buffer.hpp:37
Class holding data about a 1 dimensional vector/array.
Definition vector_view.hpp:38
VECMEM_HOST_AND_DEVICE vector_view & operator=(const vector_view< OTHERTYPE > &rhs)
Copy from a "slightly different" vecmem::details::vector_view object.
VECMEM_HOST_AND_DEVICE pointer ptr() const
Get a pointer to the vector elements.
Definition vector_view.ipp:91
VECMEM_HOST_AND_DEVICE size_type capacity() const
Get the maximum capacity of the vector.
Definition vector_view.ipp:78
VECMEM_HOST_AND_DEVICE size_type size() const
Get the size of the vector.
Definition vector_view.ipp:72
buffer_type
"Overall type" for a buffer object
Definition buffer_type.hpp:13
@ fixed_size
The buffer has a fixed number of elements.
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
VECMEM_HOST data::vector_view< T > get_data(array< T, N > &a)
Helper function creating a vecmem::data::vector_view object.
Definition array.ipp:217