span: One-dimensional Non-owning View#
2025-10-17
6 min read time
#include <raft/core/span.hpp>
-
using element_type = T#
-
using value_type = typename std::remove_cv<T>::type#
-
using size_type = std::size_t#
-
using difference_type = std::ptrdiff_t#
-
using pointer = T*#
-
using const_pointer = T const*#
-
using reference = T&#
-
using const_reference = T const&#
-
using const_iterator = const_pointer#
-
using const_reverse_iterator = thrust::reverse_iterator<const_iterator>#
- constexpr span(
Default constructor that constructs a span with size 0 and nullptr.
- inline constexpr span( ) noexcept#
Constructs a span that is a view over the range [first, first + count);.
- inline constexpr span( ) noexcept#
Constructs a span that is a view over the range [first, last)
-
template<std::size_t N>
inline constexpr span( - element_type (&arr)[N]
Constructs a span that is a view over the array arr.
-
template<class U, std::size_t OtherExtent, class = typename std::enable_if<detail::is_allowed_element_type_conversion_t<U, T>::value && detail::is_allowed_extent_conversion_t<OtherExtent, Extent>::value>>
inline constexpr span( - const span<U, is_device, OtherExtent> &other
Initialize a span class from another one who’s underlying type is convertible to element_type.
- inline constexpr auto cbegin(
- inline constexpr auto cend(
- inline constexpr _RAFT_HOST_DEVICE auto rbegin(
- inline constexpr _RAFT_HOST_DEVICE auto rend(
- inline constexpr _RAFT_HOST_DEVICE auto crbegin(
- inline constexpr _RAFT_HOST_DEVICE auto crend(
- inline constexpr auto empty(
-
template<std::size_t Count>
inline constexpr auto first(
- inline constexpr auto first(
- std::size_t _count
-
template<std::size_t Count>
inline constexpr auto last(
- inline constexpr auto last(
- std::size_t _count
-
template<std::size_t Offset, std::size_t Count = dynamic_extent>
inline constexpr auto subspan( If Count is std::dynamic_extent, r.size() == this->size() - Offset; Otherwise r.size() == Count.
- inline constexpr auto subspan( ) const -> span<element_type, is_device, dynamic_extent>#
-
template<class T, std::size_t X, class U, std::size_t Y, bool is_device>
constexpr auto operator==(
) -> bool#
-
template<class T, std::size_t X, class U, std::size_t Y, bool is_device>
constexpr auto operator!=(
)#
-
template<class T, std::size_t X, class U, std::size_t Y, bool is_device>
constexpr auto operator<(
)#
-
template<class T, std::size_t X, class U, std::size_t Y, bool is_device>
constexpr auto operator<=(
)#
-
template<class T, std::size_t X, class U, std::size_t Y, bool is_device>
constexpr auto operator>(
)#
-
template<class T, std::size_t X, class U, std::size_t Y, bool is_device>
constexpr auto operator>=(
)#
-
template<class T, bool is_device, std::size_t E>
auto as_bytes(
) noexcept -> span<const std::byte, is_device, detail::extent_as_bytes_value_t<T, E>::value># Converts a span into a view of its underlying bytes.
-
template<class T, bool is_device, std::size_t E>
auto as_writable_bytes(
) noexcept -> span<std::byte, is_device, detail::extent_as_bytes_value_t<T, E>::value># Converts a span into a mutable view of its underlying bytes.
-
template<typename T, bool is_device, std::size_t Extent = dynamic_extent>
class span# - #include <span.hpp>
The span class defined in ISO C++20. Iterator is defined as plain pointer and most of the methods have bound check on debug build.
rmm::device_uvector<float> uvec(10, rmm::cuda_stream_default); auto view = device_span<float>{uvec.data(), uvec.size()};
Public Functions
- constexpr span(
Default constructor that constructs a span with size 0 and nullptr.
- inline constexpr span( ) noexcept#
Constructs a span that is a view over the range [first, first + count);.
- inline constexpr span( ) noexcept#
Constructs a span that is a view over the range [first, last)
-
template<std::size_t N>
inline constexpr span( - element_type (&arr)[N]
Constructs a span that is a view over the array arr.
-
template<class U, std::size_t OtherExtent, class = typename std::enable_if<detail::is_allowed_element_type_conversion_t<U, T>::value && detail::is_allowed_extent_conversion_t<OtherExtent, Extent>::value>>
inline constexpr span( - const span<U, is_device, OtherExtent> &other
Initialize a span class from another one who’s underlying type is convertible to element_type.
#include <raft/core/device_span.hpp>
-
template<typename T, size_t extent = std::experimental::dynamic_extent>
using device_span = span<T, true, extent># A span class for device pointer.
#include <raft/core/host_span.hpp>