thrust

◆ device_reference() [1/2]

template<typename T>
template<typename OtherT >
__host__ __device__ thrust::device_reference< T >::device_reference ( const device_reference< OtherT > &  other,
typename thrust::detail::enable_if_convertible< typename device_reference< OtherT >::pointer, pointer >::type *  = 0 
)
inline

This copy constructor accepts a const reference to another device_reference. After this device_reference is constructed, it shall refer to the same object as other.

Parameters
otherA device_reference to copy from.

The following code snippet demonstrates the semantics of this copy constructor.

#include <assert.h>
...
thrust::device_vector<int> v(1,0);
// ref equals the object at v[0]
assert(ref == v[0]);
// the address of ref equals the address of v[0]
assert(&ref == &v[0]);
// modifying v[0] modifies ref
v[0] = 13;
assert(ref == 13);
Note
This constructor is templated primarily to allow initialization of device_reference<const T> from device_reference<T>.