vecmem 1.14.0
|
Class mimicking an std::vector
in "device code".
More...
#include <vecmem/containers/device_vector.hpp>
Public Types | |
Type definitions, mimicking @c std::vector | |
using | value_type = TYPE |
Type of the array elements. | |
using | size_type = unsigned int |
Size type for the array. | |
using | difference_type = std::ptrdiff_t |
Pointer difference type. | |
using | size_pointer = typename std::conditional< std::is_const< TYPE >::value, const size_type *, size_type * >::type |
Pointer type to the size of the array. | |
using | reference = std::add_lvalue_reference_t< value_type > |
Value reference type. | |
using | const_reference = std::add_lvalue_reference_t< std::add_const_t< value_type > > |
Constant value reference type. | |
using | pointer = std::add_pointer_t< value_type > |
Value pointer type. | |
using | const_pointer = std::add_pointer_t< std::add_const_t< value_type > > |
Constant value pointer type. | |
using | iterator = pointer |
Forward iterator type. | |
using | const_iterator = const_pointer |
Constant forward iterator type. | |
using | reverse_iterator = vecmem::details::reverse_iterator< iterator > |
Reverse iterator type. | |
using | const_reverse_iterator = vecmem::details::reverse_iterator< const_iterator > |
Constant reverse iterator type. | |
Public Member Functions | |
VECMEM_HOST_AND_DEVICE | device_vector (const data::vector_view< value_type > &data) |
Constructor, on top of a previously allocated/filled block of memory. | |
device_vector (const device_vector &parent)=default | |
Copy constructor. | |
template<typename OTHERTYPE , std::enable_if_t< std::is_convertible< OTHERTYPE, TYPE >::value, bool > = true> | |
VECMEM_HOST_AND_DEVICE | device_vector (const device_vector< OTHERTYPE > &parent) |
Copy constructor. | |
VECMEM_HOST_AND_DEVICE device_vector & | operator= (const device_vector &rhs) |
Copy assignment operator from an identical type. | |
template<typename OTHERTYPE , std::enable_if_t< std::is_convertible< OTHERTYPE, TYPE >::value, bool > = true> | |
VECMEM_HOST_AND_DEVICE device_vector & | operator= (const device_vector< OTHERTYPE > &rhs) |
Copy assignment operator from a different type. | |
template<typename OTHERTYPE , std::enable_if_t< std::is_convertible< OTHERTYPE, TYPE >::value, bool > > | |
VECMEM_HOST_AND_DEVICE device_vector< TYPE > & | operator= (const device_vector< OTHERTYPE > &rhs) |
template<typename... Args> | |
VECMEM_HOST_AND_DEVICE auto | emplace_back (Args &&... args) -> reference |
Vector element access functions | |
VECMEM_HOST_AND_DEVICE reference | at (size_type pos) |
Return a specific element of the vector in a "safe way" (non-const) | |
VECMEM_HOST_AND_DEVICE const_reference | at (size_type pos) const |
Return a specific element of the vector in a "safe way" (const) | |
VECMEM_HOST_AND_DEVICE reference | operator[] (size_type pos) |
Return a specific element of the vector (non-const) | |
VECMEM_HOST_AND_DEVICE const_reference | operator[] (size_type pos) const |
Return a specific element of the vector (const) | |
VECMEM_HOST_AND_DEVICE reference | front () |
Return the first element of the vector (non-const) | |
VECMEM_HOST_AND_DEVICE const_reference | front () const |
Return the first element of the vector (const) | |
VECMEM_HOST_AND_DEVICE reference | back () |
Return the last element of the vector (non-const) | |
VECMEM_HOST_AND_DEVICE const_reference | back () const |
Return the last element of the vector (const) | |
VECMEM_HOST_AND_DEVICE pointer | data () |
Access the underlying memory array (non-const) | |
VECMEM_HOST_AND_DEVICE const_pointer | data () const |
Access the underlying memory array (const) | |
Payload modification functions | |
VECMEM_HOST_AND_DEVICE void | assign (size_type count, const_reference value) |
Assign new values to the vector (not thread-safe) | |
template<typename InputIt , std::enable_if_t< details::is_iterator_of< InputIt, value_type >::value, bool > = true> | |
VECMEM_HOST_AND_DEVICE void | assign (InputIt other_begin, InputIt other_end) |
Assign new values to the vector (not thread-safe) | |
template<typename... Args> | |
VECMEM_HOST_AND_DEVICE reference | emplace_back (Args &&... args) |
Add a new element at the end of the vector (thread-safe) | |
VECMEM_HOST_AND_DEVICE size_type | push_back (const_reference value) |
Add a new element at the end of the vector (thread-safe) | |
VECMEM_HOST_AND_DEVICE size_type | bulk_append (size_type n) |
Default-construct a given number of elements at the end of the vector. | |
VECMEM_HOST_AND_DEVICE size_type | bulk_append (size_type n, const_reference v) |
Copy-construct a given number of elements at the end of the vector, copying the given object. | |
VECMEM_HOST_AND_DEVICE size_type | bulk_append_implicit (size_type n) |
Reserve a fixed number of slots in the array in a standards-conformant way. | |
VECMEM_HOST_AND_DEVICE size_type | bulk_append_implicit_unsafe (size_type n) |
Reserve a fixed number of slots in the array in a way that technically is ill-formed. | |
VECMEM_HOST_AND_DEVICE size_type | pop_back () |
Remove the last element of the vector (not thread-safe) | |
VECMEM_HOST_AND_DEVICE void | clear () |
Clear the vector (not thread-safe) | |
VECMEM_HOST_AND_DEVICE void | resize (size_type new_size) |
Resize the vector (not thread-safe) | |
VECMEM_HOST_AND_DEVICE void | resize (size_type new_size, const_reference value) |
Resize the vector and fill any new elements with the specified value (not thread-safe) | |
VECMEM_HOST_AND_DEVICE void | resize_implicit (size_type new_size) |
Resize a vector of implicit lifetime types. | |
VECMEM_HOST_AND_DEVICE void | resize_implicit_unsafe (size_type new_size) |
Resize a vector in constant time, unsafely deallocating non-implicit lifetime types. | |
Iterator providing functions | |
VECMEM_HOST_AND_DEVICE iterator | begin () |
Return a forward iterator pointing at the beginning of the vector. | |
VECMEM_HOST_AND_DEVICE const_iterator | begin () const |
Return a constant forward iterator pointing at the beginning of the vector. | |
VECMEM_HOST_AND_DEVICE const_iterator | cbegin () const |
Return a constant forward iterator pointing at the beginning of the vector. | |
VECMEM_HOST_AND_DEVICE iterator | end () |
Return a forward iterator pointing at the end of the vector. | |
VECMEM_HOST_AND_DEVICE const_iterator | end () const |
Return a constant forward iterator pointing at the end of the vector. | |
VECMEM_HOST_AND_DEVICE const_iterator | cend () const |
Return a constant forward iterator pointing at the end of the vector. | |
VECMEM_HOST_AND_DEVICE reverse_iterator | rbegin () |
Return a reverse iterator pointing at the end of the vector. | |
VECMEM_HOST_AND_DEVICE const_reverse_iterator | rbegin () const |
Return a constant reverse iterator pointing at the end of the vector. | |
VECMEM_HOST_AND_DEVICE const_reverse_iterator | crbegin () const |
Return a constant reverse iterator pointing at the end of the vector. | |
VECMEM_HOST_AND_DEVICE reverse_iterator | rend () |
Return a reverse iterator pointing at the beginning of the vector. | |
VECMEM_HOST_AND_DEVICE const_reverse_iterator | rend () const |
Return a constant reverse iterator pointing at the beginning of the vector. | |
VECMEM_HOST_AND_DEVICE const_reverse_iterator | crend () const |
Return a constant reverse iterator pointing at the beginning of the vector. | |
Capacity checking functions | |
VECMEM_HOST_AND_DEVICE bool | empty () const |
Check whether the vector is empty. | |
VECMEM_HOST_AND_DEVICE size_type | size () const |
Return the number of elements in the vector. | |
VECMEM_HOST_AND_DEVICE size_type | max_size () const |
Return the maximum (fixed) number of elements in the vector. | |
VECMEM_HOST_AND_DEVICE size_type | capacity () const |
Return the current (fixed) capacity of the vector. | |
Friends | |
template<typename T , template< typename > class I> | |
class | edm::device |
Class mimicking an std::vector
in "device code".
This type can be used in "generic device code" as an std::vector
that allows modification of its elements. It does not allow the vector to be resized, it just allows client code to access the data wrapped by the vector with the same interface that std::vector
provides.
VECMEM_HOST_AND_DEVICE auto vecmem::device_vector< TYPE >::bulk_append | ( | size_type | n | ) |
Default-construct a given number of elements at the end of the vector.
VECMEM_HOST_AND_DEVICE auto vecmem::device_vector< TYPE >::bulk_append | ( | size_type | n, |
const_reference | v | ||
) |
Copy-construct a given number of elements at the end of the vector, copying the given object.
VECMEM_HOST_AND_DEVICE auto vecmem::device_vector< TYPE >::bulk_append_implicit | ( | size_type | n | ) |
Reserve a fixed number of slots in the array in a standards-conformant way.
VECMEM_HOST_AND_DEVICE auto vecmem::device_vector< TYPE >::bulk_append_implicit_unsafe | ( | size_type | n | ) |
Reserve a fixed number of slots in the array in a way that technically is ill-formed.
VECMEM_HOST_AND_DEVICE void vecmem::device_vector< TYPE >::resize_implicit | ( | size_type | new_size | ) |
Resize a vector of implicit lifetime types.
VECMEM_HOST_AND_DEVICE void vecmem::device_vector< TYPE >::resize_implicit_unsafe | ( | size_type | new_size | ) |
Resize a vector in constant time, unsafely deallocating non-implicit lifetime types.