vecmem 1.14.0
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
vecmem Namespace Reference

Main namespace for the vecmem classes/functions. More...

Namespaces

namespace  cuda
 Namespace holding types that work on/with CUDA.
 
namespace  data
 Namespace holding "data types".
 
namespace  details
 Namespace for types that should not be used directly by clients.
 
namespace  edm
 Namespace for the types implementing Struct-of-Array container support.
 
namespace  hip
 Namespace holding types that work on/with ROCm/HIP.
 
namespace  sycl
 Namespace holding types that work on/with oneAPI/SYCL.
 

Classes

struct  abstract_event
 Interface that language specific "events" need to implement. More...
 
class  allocator
 An allocator class that wraps a memory resource. More...
 
class  arena_memory_resource
 Memory resource implementing an arena allocation scheme. More...
 
class  array
 Array with a fixed size, chosen during runtime. More...
 
class  atomic
 Class providing atomic operations for the VecMem code. More...
 
class  binary_page_memory_resource
 A memory manager using power-of-two pages that can be split to deal with allocation requests of various sizes. More...
 
class  choice_memory_resource
 This memory resource conditionally allocates memory. More...
 
class  coalescing_memory_resource
 This memory resource tries to allocate with several upstream resources and returns the first succesful one. More...
 
class  conditional_memory_resource
 This memory resource conditionally allocates memory. More...
 
class  contiguous_memory_resource
 Downstream allocator that ensures that allocations are contiguous. More...
 
class  copy
 Class implementing (synchronous) host <-> device memory copies. More...
 
class  debug_memory_resource
 This memory resource forwards allocation and deallocation requests to the upstream resource, but alerts the user of potential problems. More...
 
class  device_array
 Class mimicking a host-filled std::array in "device code". More...
 
class  device_vector
 Class mimicking an std::vector in "device code". More...
 
class  dummy_device_atomic_ref
 Dummy / No-op atomic reference for unsupported devices / compilers. More...
 
class  host_memory_resource
 Memory resource which wraps standard library memory allocation calls. More...
 
class  identity_memory_resource
 This memory resource forwards allocation and deallocation requests to the upstream resource. More...
 
class  instrumenting_memory_resource
 This memory resource forwards allocation and deallocation requests to the upstream resource while recording useful statistics and information about these events. More...
 
class  jagged_device_vector
 A view for jagged vectors. More...
 
class  memory_monitor
 Class collecting some basic set of memory allocation statistics. More...
 
class  pool_memory_resource
 Memory resource pooling allocations of various sizes. More...
 
class  posix_device_atomic_ref
 Custom implementation for atomic operations using "POSIX" built-ins. More...
 
struct  static_array
 Simple statically-sized array-like class designed for use in device code. More...
 
class  static_vector
 Class mimicking std::vector on top of a fixed sized array. More...
 
class  synchronized_memory_resource
 A memory resource that synchronizes the operations of an upstream resource. More...
 
class  terminal_memory_resource
 This memory resource does nothing, but it does nothing for a purpose. More...
 
struct  tuple
 Default tuple type. More...
 
struct  tuple< T, Ts... >
 Simple tuple implementation for the vecmem EDM classes. More...
 
struct  tuple_element
 Default/empty implementation for vecmem::tuple_element. More...
 
struct  tuple_element< I, tuple< Ts... > >
 Get the type of the I-th element of a tuple. More...
 

Typedefs

template<typename T >
using jagged_vector = vector< vector< T > >
 Alias type for jagged vectors with our polymorphic allocator.
 
template<typename T >
using vector = std::vector< T, vecmem::polymorphic_allocator< T > >
 Alias type for vectors with our polymorphic allocator.
 
template<typename T , device_address_space address = device_address_space::global>
using device_atomic_ref = dummy_device_atomic_ref< T, address >
 Use vecmem::dummy_device_atomic_ref as a fallback.
 
template<typename T >
using unique_obj_ptr = std::unique_ptr< T, details::unique_obj_deleter< T > >
 A unique pointer type for non-trivial objects.
 
template<typename T >
using unique_alloc_ptr = std::unique_ptr< T, details::unique_alloc_deleter< T > >
 A unique pointer type for trivial types.
 

Enumerations

enum class  device_address_space { global = 0 , local = 1 }
 Custom definition for the device memory adress space.
 
enum class  memory_order {
  relaxed = 0 , consume = 1 , acquire = 2 , release = 3 ,
  acq_rel = 4 , seq_cst = 5
}
 Custom (dummy) definition for the memory order.
 

Functions

template<typename T , std::size_t N>
VECMEM_HOST data::vector_view< Tget_data (array< T, N > &a)
 Helper function creating a vecmem::data::vector_view object.
 
template<typename T , std::size_t N>
VECMEM_HOST data::vector_view< const Tget_data (const array< T, N > &a)
 Helper function creating a vecmem::data::vector_view object.
 
template<typename TYPE >
data::jagged_vector_view< TYPE > & get_data (data::jagged_vector_buffer< TYPE > &data)
 Helper function creating a vecmem::data::jagged_vector_view object.
 
template<typename TYPE >
const data::jagged_vector_view< TYPE > & get_data (const data::jagged_vector_buffer< TYPE > &data)
 Helper function creating a vecmem::data::jagged_vector_view object.
 
template<typename TYPE >
data::jagged_vector_view< TYPE > & get_data (data::jagged_vector_data< TYPE > &data)
 Helper function creating a vecmem::data::jagged_vector_view object.
 
template<typename TYPE >
const data::jagged_vector_view< TYPE > & get_data (const data::jagged_vector_data< TYPE > &data)
 Helper function creating a vecmem::data::jagged_vector_view object.
 
template<typename TYPE >
data::vector_view< TYPE > & get_data (data::vector_buffer< TYPE > &data)
 Helper function creating a vecmem::data::vector_view object.
 
template<typename TYPE >
const data::vector_view< TYPE > & get_data (const data::vector_buffer< TYPE > &data)
 Helper function creating a vecmem::data::vector_view object.
 
template<typename TYPE >
data::jagged_vector_data< TYPEget_data (jagged_vector< TYPE > &vec, memory_resource *resource)
 Helper function creating a vecmem::data::jagged_vector_data object.
 
template<typename TYPE , typename ALLOC1 , typename ALLOC2 >
data::jagged_vector_data< TYPEget_data (std::vector< std::vector< TYPE, ALLOC1 >, ALLOC2 > &vec, memory_resource *resource)
 Helper function creating a vecmem::data::jagged_vector_data object.
 
template<typename TYPE >
data::jagged_vector_data< const TYPEget_data (const jagged_vector< TYPE > &vec, memory_resource *resource)
 Helper function creating a vecmem::data::jagged_vector_data object.
 
template<typename TYPE , typename ALLOC1 , typename ALLOC2 >
data::jagged_vector_data< const TYPEget_data (const std::vector< std::vector< TYPE, ALLOC1 >, ALLOC2 > &vec, memory_resource *resource)
 Helper function creating a vecmem::data::jagged_vector_data object.
 
template<typename T , std::size_t N>
VECMEM_HOST_AND_DEVICE bool operator== (const static_array< T, N > &lhs, const static_array< T, N > &rhs)
 Equality check on two arrays.
 
template<typename T , std::size_t N>
VECMEM_HOST_AND_DEVICE bool operator!= (const static_array< T, N > &lhs, const static_array< T, N > &rhs)
 Non-equality check on two arrays.
 
template<typename TYPE , typename ALLOC >
VECMEM_HOST data::vector_view< TYPEget_data (std::vector< TYPE, ALLOC > &vec)
 Helper function creating a vecmem::data::vector_view object.
 
template<typename TYPE , typename ALLOC >
VECMEM_HOST data::vector_view< const TYPEget_data (const std::vector< TYPE, ALLOC > &vec)
 Helper function creating a vecmem::data::vector_view object.
 
template<typename TYPE >
VECMEM_HOST data::jagged_vector_data< TYPEget_data (jagged_vector< TYPE > &vec, memory_resource *resource=nullptr)
 Helper function creating a vecmem::data::jagged_vector_data object.
 
template<typename TYPE , typename ALLOC1 , typename ALLOC2 >
VECMEM_HOST data::jagged_vector_data< TYPEget_data (std::vector< std::vector< TYPE, ALLOC1 >, ALLOC2 > &vec, memory_resource *resource)
 Helper function creating a vecmem::data::jagged_vector_data object.
 
template<typename TYPE >
VECMEM_HOST data::jagged_vector_data< const TYPEget_data (const jagged_vector< TYPE > &vec, memory_resource *resource=nullptr)
 Helper function creating a vecmem::data::jagged_vector_data object.
 
template<typename TYPE , typename ALLOC1 , typename ALLOC2 >
VECMEM_HOST data::jagged_vector_data< const TYPEget_data (const std::vector< std::vector< TYPE, ALLOC1 >, ALLOC2 > &vec, memory_resource *resource)
 Helper function creating a vecmem::data::jagged_vector_data object.
 
template<typename... VARTYPES>
VECMEM_HOST edm::view< edm::schema< VARTYPES... > > get_data (edm::buffer< edm::schema< VARTYPES... > > &buffer)
 Helper function for getting a (possibly non-const) view for a buffer.
 
template<typename... VARTYPES>
VECMEM_HOST edm::view< edm::details::add_const_t< edm::schema< VARTYPES... > > > get_data (const edm::buffer< edm::schema< VARTYPES... > > &buffer)
 Helper function for getting a (const) view for a buffer.
 
template<typename... VARTYPES>
VECMEM_HOST edm::view< edm::schema< VARTYPES... > > & get_data (edm::data< edm::schema< VARTYPES... > > &data)
 Helper function for getting a (possibly non-const) view of a data object.
 
template<typename... VARTYPES>
VECMEM_HOST edm::view< edm::details::add_const_t< edm::schema< VARTYPES... > > > get_data (const edm::data< edm::schema< VARTYPES... > > &data)
 Helper function for getting a (const) view of a data object.
 
template<typename... VARTYPES, template< typename > class INTERFACE>
VECMEM_HOST edm::data< edm::schema< VARTYPES... > > get_data (edm::host< edm::schema< VARTYPES... >, INTERFACE > &host, memory_resource *resource=nullptr)
 Helper function for getting a (non-const) data object for a host container.
 
template<typename... VARTYPES, template< typename > class INTERFACE>
VECMEM_HOST edm::data< edm::details::add_const_t< edm::schema< VARTYPES... > > > get_data (const edm::host< edm::schema< VARTYPES... >, INTERFACE > &host, memory_resource *resource=nullptr)
 Helper function for getting a (const) data object for a host container.
 
template<typename... VARTYPES, template< typename > class INTERFACE>
VECMEM_HOST void get_data_impl (edm::host< edm::schema< VARTYPES... >, INTERFACE > &, edm::data< edm::schema< VARTYPES... > > &, memory_resource &, std::index_sequence<>)
 Helper function terminal node.
 
template<typename... VARTYPES, template< typename > class INTERFACE, std::size_t I, std::size_t... Is>
VECMEM_HOST void get_data_impl (edm::host< edm::schema< VARTYPES... >, INTERFACE > &host, edm::data< edm::schema< VARTYPES... > > &data, memory_resource &mr, std::index_sequence< I, Is... >)
 Helper function recursive node.
 
template<typename... VARTYPES, template< typename > class INTERFACE>
VECMEM_HOST void get_data_impl (const edm::host< edm::schema< VARTYPES... >, INTERFACE > &, edm::data< edm::details::add_const_t< edm::schema< VARTYPES... > > > &, memory_resource &, std::index_sequence<>)
 Helper function terminal node.
 
template<typename... VARTYPES, template< typename > class INTERFACE, std::size_t I, std::size_t... Is>
VECMEM_HOST void get_data_impl (const edm::host< edm::schema< VARTYPES... >, INTERFACE > &host, edm::data< edm::details::add_const_t< edm::schema< VARTYPES... > > > &data, memory_resource &mr, std::index_sequence< I, Is... >)
 Helper function recursive node.
 
template<typename T , typename... Args>
std::enable_if_t<!std::is_array_v< T >, unique_obj_ptr< T > > make_unique_obj (memory_resource &m, Args &&... a)
 Create a unique object pointer to a newly constructed object.
 
template<typename T >
std::enable_if_t< std::is_array_v< T > &&std::extent_v< T >==0, unique_obj_ptr< T > > make_unique_obj (memory_resource &m, std::size_t n)
 Create a unique object pointer to an array of default-constructed objects.
 
template<typename T >
unique_alloc_ptr< Tmake_unique_alloc (memory_resource &m)
 Create a unique allocation pointer to a type.
 
template<typename T >
unique_alloc_ptr< Tmake_unique_alloc (memory_resource &m, std::size_t n)
 Create a unique allocation pointer to an array type.
 
template<typename T , typename C >
unique_alloc_ptr< Tmake_unique_alloc (memory_resource &m, const T *f, const C &c)
 Create a unique allocation pointer to a type, copying some existing data to it.
 
template<typename T , typename C >
unique_alloc_ptr< Tmake_unique_alloc (memory_resource &m, std::size_t n, const std::remove_extent_t< T > *f, const C &c)
 Create a unique allocation pointer to an array type, copying some existing data to it.
 

Variables

template<std::size_t I>
 reference
 
template<std::size_t I>
 const_reference
 

Utility functions for @c vecmem::tuple

template<std::size_t I, class T >
using tuple_element_t = typename tuple_element< I, T >::type
 Convenience accessor for the I-th element of a tuple.
 
template<std::size_t I, typename... Ts>
VECMEM_HOST_AND_DEVICE constexpr const autoget (const tuple< Ts... > &t) noexcept
 Get a constant element out of a tuple.
 
template<std::size_t I, typename... Ts>
VECMEM_HOST_AND_DEVICE constexpr autoget (tuple< Ts... > &t) noexcept
 Get a non-constant element out of a tuple.
 
template<typename... Ts>
VECMEM_HOST_AND_DEVICE constexpr tuple< Ts &... > tie (Ts &... args)
 Tie references to existing objects, into a tuple.
 
template<class... Ts>
VECMEM_HOST_AND_DEVICE constexpr tuple< typename std::decay< Ts >::type... > make_tuple (Ts &&... args)
 Make a tuple with automatic type deduction.
 

Detailed Description

Main namespace for the vecmem classes/functions.

Helpers for explicit calls to the SYCL atomic functions.

Namespace for the types serving as base classes for an SoA event data model.

Public classes and functions that are not language/backend specific, are generally placed in this namespace.

See also
vecmem::data

Typedef Documentation

◆ jagged_vector

Alias type for jagged vectors with our polymorphic allocator.

This type serves as an alias for a common type pattern, namely a host-accessible vector of vectors with a memory resource which is not known at compile time, which could be host memory or shared memory.

Warning
This type should only be used with host-accessible memory resources.

◆ tuple_element_t

template<std::size_t I, class T >
using vecmem::tuple_element_t = typedef typename tuple_element<I, T>::type

Convenience accessor for the I-th element of a tuple.

Template Parameters
TThe type of the tuple to investigate
IIndex of the element to get the type of

◆ unique_alloc_ptr

A unique pointer type for trivial types.

This type alias serves as a unique pointer to some trivial object(s). When the pointer goes out of scope, the pointee is automatically deallocated, but NOT deleted.

Template Parameters
TThe type of the object stored.
Note
This type supports non-array types, as well as array types with unknown bound, but not with known bound.
This type can only be used with types that are both trivially destructible and constructible.

◆ unique_obj_ptr

A unique pointer type for non-trivial objects.

This type alias serves as a unique pointer to some non-trivial object(s). When the pointer goes out of scope, the pointee is automatically deallocated and deleted.

Template Parameters
TThe type of the object stored.
Note
This type supports non-array types and array types with unknown bound, but array types with known bound are not supported.
Warning
This type should never be used with host-inaccessible memory! We cannot check this at compile-time or at run-time, so it is the responsibility of the user to ensure that this requirement is respected.

◆ vector

Alias type for vectors with our polymorphic allocator.

This type serves as an alias for a common type pattern, namely a host-accessible vector with a memory resource which is not known at compile time, which could be host memory or shared memory.

Warning
This type should only be used with host-accessible memory resources.

Function Documentation

◆ get() [1/2]

template<std::size_t I, typename... Ts>
VECMEM_HOST_AND_DEVICE constexpr const auto & vecmem::get ( const tuple< Ts... > &  t)
inlineconstexprnoexcept

Get a constant element out of a tuple.

Template Parameters
IThe index of the element to get
...TsThe types held by the tuple
Parameters
tThe tuple to get the element from
Returns
The I-th element of the tuple

◆ get() [2/2]

template<std::size_t I, typename... Ts>
VECMEM_HOST_AND_DEVICE constexpr auto & vecmem::get ( tuple< Ts... > &  t)
inlineconstexprnoexcept

Get a non-constant element out of a tuple.

Template Parameters
IThe index of the element to get
...TsThe types held by the tuple
Parameters
tThe tuple to get the element from
Returns
The I-th element of the tuple

◆ get_data() [1/6]

template<typename... VARTYPES>
VECMEM_HOST edm::view< edm::details::add_const_t< edm::schema< VARTYPES... > > > vecmem::get_data ( const edm::buffer< edm::schema< VARTYPES... > > &  buffer)

Helper function for getting a (const) view for a buffer.

Template Parameters
...VARTYPESThe variable types describing the container
Parameters
bufferThe buffer to get a view for
Returns
A (const) view into for the buffer

◆ get_data() [2/6]

template<typename... VARTYPES>
VECMEM_HOST edm::view< edm::details::add_const_t< edm::schema< VARTYPES... > > > vecmem::get_data ( const edm::data< edm::schema< VARTYPES... > > &  data)

Helper function for getting a (const) view of a data object.

Template Parameters
...VARTYPESThe variable types describing the container
Parameters
dataThe data object to get a view for
Returns
A (const) view into for the data object

◆ get_data() [3/6]

template<typename... VARTYPES, template< typename > class INTERFACE>
VECMEM_HOST edm::data< edm::details::add_const_t< edm::schema< VARTYPES... > > > vecmem::get_data ( const edm::host< edm::schema< VARTYPES... >, INTERFACE > &  host,
memory_resource *  resource = nullptr 
)

Helper function for getting a (const) data object for a host container.

Template Parameters
...VARTYPESThe variable types describing the container
Parameters
hostThe host container to get a data object for
resourceThe memory resource to use for any allocation(s)
Returns
A (const) data object describing the host container

◆ get_data() [4/6]

template<typename... VARTYPES>
VECMEM_HOST edm::view< edm::schema< VARTYPES... > > vecmem::get_data ( edm::buffer< edm::schema< VARTYPES... > > &  buffer)

Helper function for getting a (possibly non-const) view for a buffer.

Template Parameters
...VARTYPESThe variable types describing the container
Parameters
bufferThe buffer to get a view for
Returns
A (possibly non-const) view into for the buffer

◆ get_data() [5/6]

template<typename... VARTYPES>
VECMEM_HOST edm::view< edm::schema< VARTYPES... > > & vecmem::get_data ( edm::data< edm::schema< VARTYPES... > > &  data)

Helper function for getting a (possibly non-const) view of a data object.

Template Parameters
...VARTYPESThe variable types describing the container
Parameters
dataThe data object to get a view for
Returns
A (possibly non-const) view into for the data object

◆ get_data() [6/6]

template<typename... VARTYPES, template< typename > class INTERFACE>
VECMEM_HOST edm::data< edm::schema< VARTYPES... > > vecmem::get_data ( edm::host< edm::schema< VARTYPES... >, INTERFACE > &  host,
memory_resource *  resource = nullptr 
)

Helper function for getting a (non-const) data object for a host container.

Template Parameters
...VARTYPESThe variable types describing the container
Parameters
hostThe host container to get a data object for
resourceThe memory resource to use for any allocation(s)
Returns
A (non-const) data object describing the host container

◆ make_tuple()

template<class... Ts>
VECMEM_HOST_AND_DEVICE constexpr tuple< typename std::decay< Ts >::type... > vecmem::make_tuple ( Ts &&...  args)
inlineconstexpr

Make a tuple with automatic type deduction.

Template Parameters
...TsTypes deduced for the resulting tuple
Parameters
argsValues to make a tuple out of
Returns
A tuple constructed from the received values

◆ make_unique_alloc() [1/4]

template<typename T >
unique_alloc_ptr< T > vecmem::make_unique_alloc ( memory_resource &  m)

Create a unique allocation pointer to a type.

This function creates a unique allocation pointer to an allocation, which means that the memory is only deallocated, not deconstructed, when it goes out of scope.

Template Parameters
TThe type to allocate.
Parameters
mThe memory resource to use.
Returns
A unique allocation pointer to the newly allocated memory.
Note
This function can only be used with types that are trivially constructible and destructible.
Warning
In a strict sense, this method violates the semantics of C++ standards lower than C++20. This is because in C++17 and lower, object lifetimes (even for trivially default constructible ones) only starts when the object is constructed via a new operation or a constructor. We are technically not doing this, and as such the object is technically uninitialized and may not be used; it may not even be assigned. In practice, nobody really cares, but please beware. To learn more, please see the [basic.object] section of the C++ standard. C++20 resolves this problem by adding implicit object construction.

◆ make_unique_alloc() [2/4]

template<typename T , typename C >
unique_alloc_ptr< T > vecmem::make_unique_alloc ( memory_resource &  m,
const T f,
const C c 
)

Create a unique allocation pointer to a type, copying some existing data to it.

This function creates a unique allocation pointer to an allocation, which means that the memory is only deallocated, not deconstructed, when it goes out of scope.

Also, this method copies data from a host-accessible pointer to the allocated memory via some copy helper.

Template Parameters
TThe type to allocate.
CThe copy helper, which must have a method with the signature of void operator()(T* dst, T* src, std::size_t bytes).
Parameters
mThe memory resource to use.
fThe host-accessible pointer to copy from.
cThe copy helper callable object.
Returns
A unique allocation pointer to the newly allocated and copied memory.
Warning
Using this method with a copy helper that cannot write to the type of memory allocated by the given memory resource is undefined behaviour.
Note
This function can only be used with types that are trivially copyable and destructible.
Warning
In a strict sense, this method violates the semantics of C++ standards lower than C++20. This is because in C++17 and lower, object lifetimes (even for trivially default constructible ones) only starts when the object is constructed via a new operation or a constructor. We are technically not doing this, and as such the object is technically uninitialized and may not be used; it may not even be assigned. In practice, nobody really cares, but please beware. To learn more, please see the [basic.object] section of the C++ standard. C++20 resolves this problem by adding implicit object construction.

◆ make_unique_alloc() [3/4]

template<typename T >
unique_alloc_ptr< T > vecmem::make_unique_alloc ( memory_resource &  m,
std::size_t  n 
)

Create a unique allocation pointer to an array type.

This function creates a unique allocation pointer to an allocation of an array type of trivial objects, which is deallocated but not deleted when the pointer goes out of scope.

Template Parameters
TThe type to allocate.
Parameters
mThe memory resource to use.
nThe number of elements to allocate.
Returns
A unique allocation pointer to a newly allocated array.
Note
This function can only be used with types that are trivially constructible and destructible.
Warning
In a strict sense, this method violates the semantics of C++ standards lower than C++20. This is because in C++17 and lower, object lifetimes (even for trivially default constructible ones) only starts when the object is constructed via a new operation or a constructor. We are technically not doing this, and as such the object is technically uninitialized and may not be used; it may not even be assigned. In practice, nobody really cares, but please beware. To learn more, please see the [basic.object] section of the C++ standard. C++20 resolves this problem by adding implicit object construction.

◆ make_unique_alloc() [4/4]

template<typename T , typename C >
unique_alloc_ptr< T > vecmem::make_unique_alloc ( memory_resource &  m,
std::size_t  n,
const std::remove_extent_t< T > *  f,
const C c 
)

Create a unique allocation pointer to an array type, copying some existing data to it.

This function creates a unique allocation pointer to an allocation of an array type of trivial objects, which is deallocated but not deleted when the pointer goes out of scope.

Also, this method copies data from a host-accessible pointer to the allocated memory via some copy helper.

Template Parameters
TThe type to allocate.
CThe copy helper, which must have a method with the signature of void operator()(T* dst, T* src, std::size_t bytes).
Parameters
mThe memory resource to use.
nThe number of elements to allocate.
fThe host-accessible pointer to copy from.
cThe copy helper callable object.
Returns
A unique allocation pointer to a newly allocated and copied array.
Warning
Using this method with a copy helper that cannot write to the type of memory allocated by the given memory resource is undefined behaviour.
Note
This function can only be used with types that are trivially copyable and destructible.
Warning
In a strict sense, this method violates the semantics of C++ standards lower than C++20. This is because in C++17 and lower, object lifetimes (even for trivially default constructible ones) only starts when the object is constructed via a new operation or a constructor. We are technically not doing this, and as such the object is technically uninitialized and may not be used; it may not even be assigned. In practice, nobody really cares, but please beware. To learn more, please see the [basic.object] section of the C++ standard. C++20 resolves this problem by adding implicit object construction.

◆ make_unique_obj() [1/2]

template<typename T , typename... Args>
std::enable_if_t<!std::is_array_v< T >, unique_obj_ptr< T > > vecmem::make_unique_obj ( memory_resource &  m,
Args &&...  a 
)

Create a unique object pointer to a newly constructed object.

This is the vecmem analogue to std::make_unique<T>(Args...). That is to say, it allocates memory for, and then constructs, a single object. The construction uses the arguments passed to this function.

Template Parameters
TThe type to allocate.
ArgsThe argument types to pass to the constructor.
Parameters
mThe memory resource to use.
aThe arguments to pass to the constructor.
Returns
A unique object pointer to the newly constructed object.
Warning
The memory resource used by this function must be host-accessible.

◆ make_unique_obj() [2/2]

template<typename T >
std::enable_if_t< std::is_array_v< T > &&std::extent_v< T >==0, unique_obj_ptr< T > > vecmem::make_unique_obj ( memory_resource &  m,
std::size_t  n 
)

Create a unique object pointer to an array of default-constructed objects.

This is the vecmem analogue of std::make_unique<T>(std::size_t). That is to say, it allocates an array of compile-time-unknown bounds, where the size is given by the argument. The objects are all default-constructed.

Template Parameters
TThe type to allocate.
Parameters
mThe memory resource to use.
nThe number of elements to allocate.
Returns
A unique object pointer to the newly constructed array of objects.
Warning
The memory resource used by this function must be host-accessible.

◆ tie()

template<typename... Ts>
VECMEM_HOST_AND_DEVICE constexpr tuple< Ts &... > vecmem::tie ( Ts &...  args)
inlineconstexpr

Tie references to existing objects, into a tuple.

Template Parameters
...TsTypes to refer to with the resulting tuple
Parameters
...argsReferences to the objects that the tuple should point to
Returns
A tuple of references to some existing objects

Variable Documentation

◆ const_reference

template<std::size_t I>
vecmem::const_reference
Initial value:
{
return m_array[I]

◆ reference

template<std::size_t I>
vecmem::reference
Initial value:
{
return m_array[I]