Public Types | Public Member Functions | List of all members
cudf::host_span< T, Extent > Struct Template Reference

C++20 std::span with reduced feature set. More...

#include <span.hpp>

Inheritance diagram for cudf::host_span< T, Extent >:
cudf::detail::span_base< T, cudf::dynamic_extent, host_span< T, cudf::dynamic_extent > >

Public Types

using base = cudf::detail::span_base< T, Extent, host_span< T, Extent > >
 Base type.
 
- Public Types inherited from cudf::detail::span_base< T, cudf::dynamic_extent, host_span< T, cudf::dynamic_extent > >
using element_type = T
 The type of the elements in the span.
 
using value_type = std::remove_cv< T >
 Stored value type.
 
using size_type = std::size_t
 The type used for the size of the span.
 
using difference_type = std::ptrdiff_t
 std::ptrdiff_t
 
using pointer = T *
 The type of the pointer returned by data()
 
using iterator = T *
 The type of the iterator returned by begin()
 
using const_pointer = T const *
 The type of the pointer returned by data() const.
 
using reference = T &
 The type of the reference returned by operator[](size_type)
 
using const_reference = T const &
 The type of the reference returned by operator[](size_type) const.
 

Public Member Functions

constexpr host_span (T *data, std::size_t size, bool is_device_accessible)
 
template<typename C , std::enable_if_t< is_host_span_supported_container< C >::value &&std::is_convertible_v< std::remove_pointer_t< decltype(thrust::raw_pointer_cast(std::declval< C & >().data()))>(*)[], T(*)[]> , * = nullptr>
constexpr host_span (C &in)
 
template<typename C , std::enable_if_t< is_host_span_supported_container< C >::value &&std::is_convertible_v< std::remove_pointer_t< decltype(thrust::raw_pointer_cast(std::declval< C & >().data()))>(*)[], T(*)[]> , * = nullptr>
constexpr host_span (C const &in)
 
template<typename OtherT , std::enable_if_t< std::is_convertible_v< OtherT(*)[], T(*)[]>> * = nullptr>
constexpr host_span (cudf::detail::host_vector< OtherT > &in)
 
template<typename OtherT , std::enable_if_t< std::is_convertible_v< OtherT(*)[], T(*)[]>> * = nullptr>
constexpr host_span (cudf::detail::host_vector< OtherT > const &in)
 
template<typename OtherT , std::size_t OtherExtent, std::enable_if_t<(Extent==OtherExtent||Extent==dynamic_extent) &&std::is_convertible_v< OtherT(*)[], T(*)[]>, void > * = nullptr>
constexpr host_span (host_span< OtherT, OtherExtent > const &other) noexcept
 
constexpr base::reference operator[] (size_type idx) const
 Returns a reference to the idx-th element of the sequence. More...
 
constexpr base::reference front () const
 Returns a reference to the first element in the span. More...
 
constexpr base::reference back () const
 Returns a reference to the last element in the span. More...
 
bool is_device_accessible () const
 Returns whether the data is device accessible (e.g. pinned memory) More...
 
constexpr host_span subspan (typename base::size_type offset, typename base::size_type count) const noexcept
 Obtains a span that is a view over the count elements of this span starting at offset. More...
 
- Public Member Functions inherited from cudf::detail::span_base< T, cudf::dynamic_extent, host_span< T, cudf::dynamic_extent > >
constexpr CUDF_HOST_DEVICE span_base (pointer data, size_type size)
 Constructs a span from a pointer and a size. More...
 
constexpr CUDF_HOST_DEVICE span_base (span_base const &) noexcept=default
 Copy constructor.
 
constexpr CUDF_HOST_DEVICE span_baseoperator= (span_base const &) noexcept=default
 Copy assignment operator. More...
 
constexpr CUDF_HOST_DEVICE iterator begin () const noexcept
 Returns an iterator to the first element of the span. More...
 
constexpr CUDF_HOST_DEVICE iterator end () const noexcept
 Returns an iterator to the element following the last element of the span. More...
 
constexpr CUDF_HOST_DEVICE pointer data () const noexcept
 Returns a pointer to the beginning of the sequence. More...
 
constexpr CUDF_HOST_DEVICE size_type size () const noexcept
 Returns the number of elements in the span. More...
 
constexpr CUDF_HOST_DEVICE size_type size_bytes () const noexcept
 Returns the size of the sequence in bytes. More...
 
constexpr CUDF_HOST_DEVICE bool empty () const noexcept
 Checks if the span is empty. More...
 
constexpr host_span< T, cudf::dynamic_extentfirst (size_type count) const noexcept
 Obtains a subspan consisting of the first N elements of the sequence. More...
 
constexpr host_span< T, cudf::dynamic_extentlast (size_type count) const noexcept
 Obtains a subspan consisting of the last N elements of the sequence. More...
 

Additional Inherited Members

- Static Public Attributes inherited from cudf::detail::span_base< T, cudf::dynamic_extent, host_span< T, cudf::dynamic_extent > >
static constexpr std::size_t extent
 The extent of the span.
 
- Protected Attributes inherited from cudf::detail::span_base< T, cudf::dynamic_extent, host_span< T, cudf::dynamic_extent > >
pointer _data
 Pointer to the first element in the span.
 
size_type _size
 The number of elements in the span.
 

Detailed Description

template<typename T, std::size_t Extent = cudf::dynamic_extent>
struct cudf::host_span< T, Extent >

C++20 std::span with reduced feature set.

Definition at line 194 of file span.hpp.

Constructor & Destructor Documentation

◆ host_span() [1/6]

template<typename T , std::size_t Extent = cudf::dynamic_extent>
constexpr cudf::host_span< T, Extent >::host_span ( T *  data,
std::size_t  size,
bool  is_device_accessible 
)
inlineconstexpr

Constructor from pointer and size

Parameters
dataPointer to the first element in the span
sizeThe number of elements in the span
is_device_accessibleWhether the data is device accessible (e.g. pinned memory)

Definition at line 204 of file span.hpp.

◆ host_span() [2/6]

template<typename T , std::size_t Extent = cudf::dynamic_extent>
template<typename C , std::enable_if_t< is_host_span_supported_container< C >::value &&std::is_convertible_v< std::remove_pointer_t< decltype(thrust::raw_pointer_cast(std::declval< C & >().data()))>(*)[], T(*)[]> , * = nullptr>
constexpr cudf::host_span< T, Extent >::host_span ( C &  in)
inlineconstexpr

Constructor from container

Parameters
inThe container to construct the span from

Definition at line 218 of file span.hpp.

◆ host_span() [3/6]

template<typename T , std::size_t Extent = cudf::dynamic_extent>
template<typename C , std::enable_if_t< is_host_span_supported_container< C >::value &&std::is_convertible_v< std::remove_pointer_t< decltype(thrust::raw_pointer_cast(std::declval< C & >().data()))>(*)[], T(*)[]> , * = nullptr>
constexpr cudf::host_span< T, Extent >::host_span ( C const &  in)
inlineconstexpr

Constructor from const container

Parameters
inThe container to construct the span from

Definition at line 231 of file span.hpp.

◆ host_span() [4/6]

template<typename T , std::size_t Extent = cudf::dynamic_extent>
template<typename OtherT , std::enable_if_t< std::is_convertible_v< OtherT(*)[], T(*)[]>> * = nullptr>
constexpr cudf::host_span< T, Extent >::host_span ( cudf::detail::host_vector< OtherT > &  in)
inlineconstexpr

Constructor from a host_vector

Parameters
inThe host_vector to construct the span from

Definition at line 240 of file span.hpp.

◆ host_span() [5/6]

template<typename T , std::size_t Extent = cudf::dynamic_extent>
template<typename OtherT , std::enable_if_t< std::is_convertible_v< OtherT(*)[], T(*)[]>> * = nullptr>
constexpr cudf::host_span< T, Extent >::host_span ( cudf::detail::host_vector< OtherT > const &  in)
inlineconstexpr

Constructor from a const host_vector

Parameters
inThe host_vector to construct the span from

Definition at line 250 of file span.hpp.

◆ host_span() [6/6]

template<typename T , std::size_t Extent = cudf::dynamic_extent>
template<typename OtherT , std::size_t OtherExtent, std::enable_if_t<(Extent==OtherExtent||Extent==dynamic_extent) &&std::is_convertible_v< OtherT(*)[], T(*)[]>, void > * = nullptr>
constexpr cudf::host_span< T, Extent >::host_span ( host_span< OtherT, OtherExtent > const &  other)
inlineconstexprnoexcept
Parameters
otherThe span to copy

Definition at line 262 of file span.hpp.

Member Function Documentation

◆ back()

template<typename T , std::size_t Extent = cudf::dynamic_extent>
constexpr base::reference cudf::host_span< T, Extent >::back ( ) const
inlineconstexpr

Returns a reference to the last element in the span.

Calling last on an empty span results in undefined behavior.

Returns
Reference to the last element in the span

Definition at line 295 of file span.hpp.

◆ front()

template<typename T , std::size_t Extent = cudf::dynamic_extent>
constexpr base::reference cudf::host_span< T, Extent >::front ( ) const
inlineconstexpr

Returns a reference to the first element in the span.

Calling front on an empty span results in undefined behavior.

Returns
Reference to the first element in the span

Definition at line 286 of file span.hpp.

◆ is_device_accessible()

template<typename T , std::size_t Extent = cudf::dynamic_extent>
bool cudf::host_span< T, Extent >::is_device_accessible ( ) const
inline

Returns whether the data is device accessible (e.g. pinned memory)

Returns
true if the data is device accessible

Definition at line 305 of file span.hpp.

◆ operator[]()

template<typename T , std::size_t Extent = cudf::dynamic_extent>
constexpr base::reference cudf::host_span< T, Extent >::operator[] ( size_type  idx) const
inlineconstexpr

Returns a reference to the idx-th element of the sequence.

The behavior is undefined if idx is out of range (i.e., if it is greater than or equal to size()).

Parameters
idxthe index of the element to access
Returns
A reference to the idx-th element of the sequence, i.e., data()[idx]

Definition at line 276 of file span.hpp.

◆ subspan()

template<typename T , std::size_t Extent = cudf::dynamic_extent>
constexpr host_span cudf::host_span< T, Extent >::subspan ( typename base::size_type  offset,
typename base::size_type  count 
) const
inlineconstexprnoexcept

Obtains a span that is a view over the count elements of this span starting at offset.

Parameters
offsetThe offset of the first element in the subspan
countThe number of elements in the subspan
Returns
A subspan of the sequence, of requested count and offset

Definition at line 314 of file span.hpp.


The documentation for this struct was generated from the following file: