thrust::pointer#
-
template<typename Element, typename Tag, typename Reference, typename Derived>
class pointer : public thrust::iterator_adaptor<Derived, Base, Value, System, Traversal, Reference, Difference># pointer
stores a pointer to an object allocated in memory. Likedevice_ptr
, this type ensures type safety when dispatching standard algorithms on ranges resident in memory.pointer
generalizesdevice_ptr
by relaxing the backend system associated with thepointer
. Instead of the backend system specified byTHRUST_DEVICE_SYSTEM
,pointer's
system is given by its second template parameter,Tag
. For the purpose of Thrust dispatch,device_ptr<Element>
andpointer<Element,device_system_tag>
are considered equivalent.The raw pointer encapsulated by a
pointer
may be obtained through itsget
member function or theraw_pointer_cast
free function.See also
See also
reference
See also
Note
pointer
is not a smart pointer; it is the client’s responsibility to deallocate memory pointer to bypointer
.- Template Parameters:
Element – specifies the type of the pointed-to object.
Tag – specifies the system with which this
pointer
is associated. This may be any Thrust backend system, or a user-defined tag.Reference – allows the client to specify the reference type returned upon derereference. By default, this type is
reference<Element,pointer>
.Derived – allows the client to specify the name of the derived type when
pointer
is used as a base class. This is useful to ensure that arithmetic on values of the derived type return values of the derived type as a result. By default, this type ispointer<Element,Tag,Reference>
.
Public Types
-
using raw_pointer = typename super_t::base_type#
The type of the raw pointer
-
using base_type = Base#
The type of iterator this
iterator_adaptor's
adapts
.
Public Functions
-
inline pointer()#
pointer's
default constructor initializes its encapsulated pointer to0
-
inline pointer(::cuda::std::nullptr_t)#
-
template<typename OtherElement>
inline explicit pointer( - OtherElement *ptr,
This constructor allows construction of a
pointer<const T, ...>
from aT*
.- Parameters:
ptr – A raw pointer to copy from, presumed to point to a location in
Tag's
memory.- Template Parameters:
OtherElement –
OtherElement
shall be convertible toElement
.
-
template<typename OtherPointer, typename detail::enable_if_pointer_is_convertible<OtherPointer, pointer>::type* = nullptr>
inline pointer( - const OtherPointer &other,
This constructor allows initialization from another pointer-like object.
- Parameters:
other – The
OtherPointer
to copy.- Template Parameters:
OtherPointer – The tag associated with
OtherPointer
shall be convertible toTag
, and its element type shall be convertible toElement
.
-
inline derived_type &operator=(::cuda::std::nullptr_t)#
-
template<typename OtherPointer>
inline detail::enable_if_pointer_is_convertible<OtherPointer, pointer, derived_type&>::type operator=( - const OtherPointer &other,
Assignment operator allows assigning from another pointer-like object whose element type is convertible to
Element
.- Parameters:
other – The other pointer-like object to assign from.
- Template Parameters:
OtherPointer – The tag associated with
OtherPointer
shall be convertible toTag
, and its element type shall be convertible toElement
.- Returns:
*this
-
inline Element *get() const#
get
returns thispointer's
encapsulated raw pointer.- Returns:
This
pointer's
raw pointer.
-
inline explicit operator bool() const#
-
inline Base const &base() const#
- Returns:
A
const
reference to theBase
iterator thisiterator_adaptor
adapts.
Public Static Functions