vecmem 1.14.0
Loading...
Searching...
No Matches
jagged_vector_view.hpp
1/*
2 * VecMem project, part of the ACTS project (R&D line)
3 *
4 * (c) 2021-2025 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/containers/data/vector_view.hpp"
13#include "vecmem/utils/type_traits.hpp"
14#include "vecmem/utils/types.hpp"
15
16// System include(s).
17#include <cstddef>
18#include <type_traits>
19
20namespace vecmem {
21namespace data {
43template <typename T>
45
47 static_assert(!std::is_same<std::remove_cv_t<T>, bool>::value,
48 "bool is not supported in VecMem containers");
49
50public:
52 using size_type = std::size_t;
56 using pointer = std::add_pointer_t<value_type>;
57
61 jagged_vector_view() = default;
65 VECMEM_HOST_AND_DEVICE
67
77 template <
78 typename OTHERTYPE,
79 std::enable_if_t<details::is_same_nc<T, OTHERTYPE>::value, bool> = true>
80 VECMEM_HOST_AND_DEVICE jagged_vector_view(
81 const jagged_vector_view<OTHERTYPE>& parent);
82
84 template <
85 typename OTHERTYPE,
86 std::enable_if_t<details::is_same_nc<T, OTHERTYPE>::value, bool> = true>
87 VECMEM_HOST_AND_DEVICE jagged_vector_view& operator=(
89
92 template <
93 typename OTHERTYPE,
94 std::enable_if_t<std::is_same<std::remove_cv_t<T>,
95 std::remove_cv_t<OTHERTYPE> >::value,
96 bool> = true>
97 VECMEM_HOST_AND_DEVICE bool operator==(
99
101 template <
102 typename OTHERTYPE,
103 std::enable_if_t<std::is_same<std::remove_cv_t<T>,
104 std::remove_cv_t<OTHERTYPE> >::value,
105 bool> = true>
106 VECMEM_HOST_AND_DEVICE bool operator!=(
108
110 VECMEM_HOST_AND_DEVICE
111 size_type size() const;
113 VECMEM_HOST_AND_DEVICE
114 size_type capacity() const;
115
117 VECMEM_HOST_AND_DEVICE
118 pointer ptr() const;
119
132 VECMEM_HOST_AND_DEVICE
133 pointer host_ptr() const;
134
135private:
139 size_type m_size;
140
145 pointer m_ptr;
146
148 pointer m_host_ptr;
149
150}; // struct jagged_vector_view
151
152} // namespace data
153} // namespace vecmem
154
155// Include the implementation.
156#include "vecmem/containers/impl/jagged_vector_view.ipp"
A view for jagged vectors.
Definition jagged_vector_view.hpp:44
VECMEM_HOST_AND_DEVICE pointer host_ptr() const
Access the host accessible array describing the inner vectors.
Definition jagged_vector_view.ipp:102
VECMEM_HOST_AND_DEVICE jagged_vector_view & operator=(const jagged_vector_view< OTHERTYPE > &rhs)
Assignment operator from a "slightly different" object.
std::size_t size_type
We cannot use boolean types.
Definition jagged_vector_view.hpp:52
std::add_pointer_t< value_type > pointer
Pointer type to the jagged array.
Definition jagged_vector_view.hpp:56
VECMEM_HOST_AND_DEVICE bool operator!=(const jagged_vector_view< OTHERTYPE > &rhs) const
Inequality check. Simply based on operator==.
Definition jagged_vector_view.ipp:76
jagged_vector_view()=default
Default constructor.
VECMEM_HOST_AND_DEVICE size_type capacity() const
Get the maximum capacity of the "outer" vector.
Definition jagged_vector_view.ipp:89
VECMEM_HOST_AND_DEVICE bool operator==(const jagged_vector_view< OTHERTYPE > &rhs) const
Equality check.
Definition jagged_vector_view.ipp:61
VECMEM_HOST_AND_DEVICE pointer ptr() const
Get a pointer to the vector elements.
Definition jagged_vector_view.ipp:96
VECMEM_HOST_AND_DEVICE size_type size() const
Get the "outer" size of the jagged vector.
Definition jagged_vector_view.ipp:83
vector_view< T > value_type
Value type of the jagged array.
Definition jagged_vector_view.hpp:54
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