vecmem 1.18.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#include <vector>
20
21namespace vecmem {
22namespace data {
44template <typename T>
46
48 static_assert(!std::is_same<std::remove_cv_t<T>, bool>::value,
49 "bool is not supported in VecMem containers");
50
51public:
53 using size_type = std::size_t;
57 using pointer = std::add_pointer_t<value_type>;
58
62 jagged_vector_view() = default;
66 VECMEM_HOST_AND_DEVICE
68
78 template <
79 typename OTHERTYPE,
80 std::enable_if_t<details::is_same_nc<T, OTHERTYPE>::value, bool> = true>
81 VECMEM_HOST_AND_DEVICE jagged_vector_view(
82 const jagged_vector_view<OTHERTYPE>& parent);
83
85 template <
86 typename OTHERTYPE,
87 std::enable_if_t<details::is_same_nc<T, OTHERTYPE>::value, bool> = true>
88 VECMEM_HOST_AND_DEVICE jagged_vector_view& operator=(
90
93 template <
94 typename OTHERTYPE,
95 std::enable_if_t<std::is_same<std::remove_cv_t<T>,
96 std::remove_cv_t<OTHERTYPE> >::value,
97 bool> = true>
98 VECMEM_HOST_AND_DEVICE bool operator==(
100
102 template <
103 typename OTHERTYPE,
104 std::enable_if_t<std::is_same<std::remove_cv_t<T>,
105 std::remove_cv_t<OTHERTYPE> >::value,
106 bool> = true>
107 VECMEM_HOST_AND_DEVICE bool operator!=(
109
111 VECMEM_HOST_AND_DEVICE
112 size_type size() const;
114 VECMEM_HOST_AND_DEVICE
115 size_type capacity() const;
116
118 VECMEM_HOST_AND_DEVICE
119 pointer ptr() const;
120
133 VECMEM_HOST_AND_DEVICE
134 pointer host_ptr() const;
135
136private:
140 size_type m_size;
141
146 pointer m_ptr;
147
149 pointer m_host_ptr;
150
151}; // struct jagged_vector_view
152
160template <typename T>
161VECMEM_HOST std::vector<typename vector_view<T>::size_type> get_capacities(
162 const jagged_vector_view<T>& data);
163
164} // namespace data
165} // namespace vecmem
166
167// Include the implementation.
168#include "vecmem/containers/impl/jagged_vector_view.ipp"
An allocator class that wraps a memory resource.
Definition allocator.hpp:37
A view for jagged vectors.
Definition jagged_vector_view.hpp:45
VECMEM_HOST_AND_DEVICE pointer host_ptr() const
Access the host accessible array describing the inner vectors.
Definition jagged_vector_view.ipp:105
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:53
std::add_pointer_t< value_type > pointer
Pointer type to the jagged array.
Definition jagged_vector_view.hpp:57
VECMEM_HOST_AND_DEVICE bool operator!=(const jagged_vector_view< OTHERTYPE > &rhs) const
Inequality check. Simply based on operator==.
Definition jagged_vector_view.ipp:79
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:92
VECMEM_HOST_AND_DEVICE bool operator==(const jagged_vector_view< OTHERTYPE > &rhs) const
Equality check.
Definition jagged_vector_view.ipp:64
VECMEM_HOST_AND_DEVICE pointer ptr() const
Get a pointer to the vector elements.
Definition jagged_vector_view.ipp:99
VECMEM_HOST_AND_DEVICE size_type size() const
Get the "outer" size of the jagged vector.
Definition jagged_vector_view.ipp:86
VECMEM_HOST std::vector< typename vector_view< T >::size_type > get_capacities(const jagged_vector_view< T > &data)
Get the capacities of the inner vectors of a jagged vector.
Definition jagged_vector_view.ipp:111
Main namespace for the vecmem classes/functions.
Definition atomic_ref.hpp:16