10#include "vecmem/containers/details/resize_jagged_vector.hpp"
11#include "vecmem/containers/jagged_vector.hpp"
12#include "vecmem/containers/vector.hpp"
13#include "vecmem/edm/details/schema_traits.hpp"
14#include "vecmem/edm/schema.hpp"
15#include "vecmem/memory/memory_resource.hpp"
23namespace vecmem::edm::details {
28template <
typename TYPE>
31template <
typename TYPE>
34 using return_type = std::add_lvalue_reference_t<TYPE>;
35 using const_return_type =
36 std::add_lvalue_reference_t<std::add_const_t<TYPE>>;
39template <
typename TYPE>
42 using return_type = std::add_lvalue_reference_t<type>;
43 using const_return_type =
44 std::add_lvalue_reference_t<std::add_const_t<type>>;
47template <
typename TYPE>
50 using return_type = std::add_lvalue_reference_t<type>;
51 using const_return_type =
52 std::add_lvalue_reference_t<std::add_const_t<type>>;
57 using type =
typename host_type<
typename std::tuple_element<
59 using return_type =
typename host_type<
typename std::tuple_element<
61 using const_return_type =
typename host_type<
typename std::tuple_element<
70template <
typename TYPE>
77template <
typename TYPE>
80 memory_resource&
mr) {
94std::size_t get_host_size(
96 std::index_sequence<INDEX, Is...>, std::size_t size = 0,
111 throw std::length_error(
112 "Inconsistent variable sizes in host container!");
115 if constexpr (
sizeof...(Is) == 0) {
117 throw std::length_error(
118 "Could not determine the size of the host container?!?");
122 return get_host_size<
VARTYPES...>(data, std::index_sequence<
Is...>{},
135void host_resize(std::tuple<
typename host_type<VARTYPES>::type...>& data,
136 std::size_t size, std::index_sequence<INDEX, Is...>) {
139 if constexpr (type::details::is_jagged_vector_v<
typename std::tuple_element<
142 }
else if constexpr (type::details::is_vector_v<
typename std::tuple_element<
144 std::get<INDEX>(data).resize(size);
147 if constexpr (
sizeof...(Is) > 0) {
148 host_resize<
VARTYPES...>(data, size, std::index_sequence<
Is...>{});
159void host_reserve(std::tuple<
typename host_type<VARTYPES>::type...>& data,
160 std::size_t size, std::index_sequence<INDEX, Is...>) {
163 if constexpr (type::details::is_vector<
typename std::tuple_element<
165 std::get<INDEX>(data).reserve(size);
168 if constexpr (
sizeof...(Is) > 0) {
169 host_reserve<
VARTYPES...>(data, size, std::index_sequence<
Is...>{});
Technical base type for data<schema<VARTYPES...>>
Definition data.hpp:25
void resize_jagged_vector(std::vector< std::vector< T, ALLOC1 >, ALLOC2 > &vec, std::size_t size)
Resize a generic jagged vector.
Definition resize_jagged_vector.hpp:23
vector< vector< T > > jagged_vector
Alias type for jagged vectors with our polymorphic allocator.
Definition jagged_vector.hpp:30
std::vector< T, vecmem::polymorphic_allocator< T > > vector
Alias type for vectors with our polymorphic allocator.
Definition vector.hpp:35
Definition host_traits.hpp:71
Definition host_traits.hpp:56
Definition host_traits.hpp:29
Definition schema_traits.hpp:64