WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
wpi::rotated_span< T, Extent > Class Template Reference

This is a simple rotated span view. More...

#include <wpi/rotated_span.h>

Classes

class  iterator
 

Public Types

using element_type = T
 
using value_type = std::remove_cv_t<T>
 
using size_type = size_t
 
using difference_type = std::ptrdiff_t
 
using pointer = T*
 
using const_pointer = const T*
 
using reference = element_type&
 
using const_reference = const element_type&
 
using reverse_iterator = std::reverse_iterator<iterator>
 

Public Member Functions

constexpr rotated_span () noexcept=default
 
constexpr rotated_span (std::span< T, Extent > data, int rotation=0)
 
template<std::contiguous_iterator It>
constexpr explicit (extent !=std::dynamic_extent) rotated_span(It first
 
constexpr size_type int std::sized_sentinel_for< It > End constexpr explicit (extent !=std::dynamic_extent) rotated_span(It first
 
constexpr size_type int std::sized_sentinel_for< It > End constexpr End int size_t ArrayExtent constexpr rotated_span (std::array< Tp, ArrayExtent > &arr, int rotation=0) noexcept
 
template<typename Tp , size_t ArrayExtent>
constexpr rotated_span (const std::array< Tp, ArrayExtent > &arr, int rotation=0) noexcept
 
template<typename OType , size_t OExtent>
requires (Extent == std::dynamic_extent || OExtent == std::dynamic_extent || Extent == OExtent)
constexpr explicit (extent !=std::dynamic_extent &&OExtent==std::dynamic_extent) rotated_span(const rotated_span< OType
 
constexpr rotated_span (rotated_span &&) noexcept=default
 
constexpr rotated_spanoperator= (rotated_span &&) noexcept=default
 
 ~rotated_span () noexcept=default
 
constexpr std::span< T, Extent > data () const noexcept
 
constexpr size_type offset () const noexcept
 
constexpr size_type size () const noexcept
 
constexpr size_type size_bytes () const noexcept
 
constexpr bool empty () const noexcept
 
constexpr reference front () const noexcept
 
constexpr reference back () const noexcept
 
constexpr reference operator[] (size_type idx) const noexcept
 
constexpr iterator begin () const noexcept
 
constexpr iterator end () const noexcept
 
constexpr reverse_iterator rbegin () const noexcept
 
constexpr reverse_iterator rend () const noexcept
 
constexpr rotated_span rotate (int amt) const noexcept
 

Public Attributes

constexpr size_type count
 
constexpr size_type int rotation
 
constexpr size_type int std::sized_sentinel_for< It > End constexpr End last
 
constexpr size_type int std::sized_sentinel_for< It > End constexpr End int rotation
 
constexpr OExtent & other
 
constexpr OExtent int rotation noexcept: m_data{other.m_data}
 
constexpr OExtent int rotation m_offset
 

Static Public Attributes

static constexpr size_t extent = Extent
 

Detailed Description

template<typename T, size_t Extent = std::dynamic_extent>
class wpi::rotated_span< T, Extent >

This is a simple rotated span view.

Indexed/iterated access provides a continuous view of the underlying span that wraps at the span size. An internal offset determines the starting location.

Constructors take a "rotation" value–if positive, the offset is the same as the rotation; if negative, the offset is set relative to the end of the array.

For example, given an array of 5 values, providing a rotation value of 2 will result in an index of 0 accessing underlying span index 2, index 2 accessing underlying span index 4, and index 4 accessing underlying span index 1.

Similarly, providing a rotation value of -2 will result in index 0 accessing underlying span index 3 (5-2), index 2 accessing underlying span index 0, and index 4 accessing underlying span index 2.

Template Parameters
Telement type
Extentstatic sized extent, or std::dynamic_extent

Member Typedef Documentation

◆ const_pointer

template<typename T , size_t Extent = std::dynamic_extent>
using wpi::rotated_span< T, Extent >::const_pointer = const T*

◆ const_reference

template<typename T , size_t Extent = std::dynamic_extent>
using wpi::rotated_span< T, Extent >::const_reference = const element_type&

◆ difference_type

template<typename T , size_t Extent = std::dynamic_extent>
using wpi::rotated_span< T, Extent >::difference_type = std::ptrdiff_t

◆ element_type

template<typename T , size_t Extent = std::dynamic_extent>
using wpi::rotated_span< T, Extent >::element_type = T

◆ pointer

template<typename T , size_t Extent = std::dynamic_extent>
using wpi::rotated_span< T, Extent >::pointer = T*

◆ reference

template<typename T , size_t Extent = std::dynamic_extent>
using wpi::rotated_span< T, Extent >::reference = element_type&

◆ reverse_iterator

template<typename T , size_t Extent = std::dynamic_extent>
using wpi::rotated_span< T, Extent >::reverse_iterator = std::reverse_iterator<iterator>

◆ size_type

template<typename T , size_t Extent = std::dynamic_extent>
using wpi::rotated_span< T, Extent >::size_type = size_t

◆ value_type

template<typename T , size_t Extent = std::dynamic_extent>
using wpi::rotated_span< T, Extent >::value_type = std::remove_cv_t<T>

Constructor & Destructor Documentation

◆ rotated_span() [1/5]

template<typename T , size_t Extent = std::dynamic_extent>
wpi::rotated_span< T, Extent >::rotated_span ( )
constexprdefaultnoexcept

◆ rotated_span() [2/5]

template<typename T , size_t Extent = std::dynamic_extent>
wpi::rotated_span< T, Extent >::rotated_span ( std::span< T, Extent > data,
int rotation = 0 )
inlineconstexpr

◆ rotated_span() [3/5]

template<typename T , size_t Extent = std::dynamic_extent>
size_type int std::sized_sentinel_for< It > End constexpr End int size_t ArrayExtent constexpr wpi::rotated_span< T, Extent >::rotated_span ( std::array< Tp, ArrayExtent > & arr,
int rotation = 0 )
inlineconstexprnoexcept

◆ rotated_span() [4/5]

template<typename T , size_t Extent = std::dynamic_extent>
template<typename Tp , size_t ArrayExtent>
wpi::rotated_span< T, Extent >::rotated_span ( const std::array< Tp, ArrayExtent > & arr,
int rotation = 0 )
inlineconstexprnoexcept

◆ rotated_span() [5/5]

template<typename T , size_t Extent = std::dynamic_extent>
wpi::rotated_span< T, Extent >::rotated_span ( rotated_span< T, Extent > && )
constexprdefaultnoexcept

◆ ~rotated_span()

template<typename T , size_t Extent = std::dynamic_extent>
wpi::rotated_span< T, Extent >::~rotated_span ( )
defaultnoexcept

Member Function Documentation

◆ back()

template<typename T , size_t Extent = std::dynamic_extent>
reference wpi::rotated_span< T, Extent >::back ( ) const
inlinenodiscardconstexprnoexcept

◆ begin()

template<typename T , size_t Extent = std::dynamic_extent>
iterator wpi::rotated_span< T, Extent >::begin ( ) const
inlinenodiscardconstexprnoexcept

◆ data()

template<typename T , size_t Extent = std::dynamic_extent>
std::span< T, Extent > wpi::rotated_span< T, Extent >::data ( ) const
inlineconstexprnoexcept

◆ empty()

template<typename T , size_t Extent = std::dynamic_extent>
bool wpi::rotated_span< T, Extent >::empty ( ) const
inlineconstexprnoexcept

◆ end()

template<typename T , size_t Extent = std::dynamic_extent>
iterator wpi::rotated_span< T, Extent >::end ( ) const
inlinenodiscardconstexprnoexcept

◆ explicit() [1/3]

template<typename T , size_t Extent = std::dynamic_extent>
template<typename OType , size_t OExtent>
requires (Extent == std::dynamic_extent || OExtent == std::dynamic_extent || Extent == OExtent)
wpi::rotated_span< T, Extent >::explicit ( extent ! = std::dynamic_extent && OExtent == std::dynamic_extent) const
constexpr

◆ explicit() [2/3]

template<typename T , size_t Extent = std::dynamic_extent>
template<std::contiguous_iterator It>
wpi::rotated_span< T, Extent >::explicit ( extent ! = std::dynamic_extent)
constexpr

◆ explicit() [3/3]

template<typename T , size_t Extent = std::dynamic_extent>
size_type int std::sized_sentinel_for< It > End constexpr wpi::rotated_span< T, Extent >::explicit ( extent ! = std::dynamic_extent)
constexpr

◆ front()

template<typename T , size_t Extent = std::dynamic_extent>
reference wpi::rotated_span< T, Extent >::front ( ) const
inlinenodiscardconstexprnoexcept

◆ offset()

template<typename T , size_t Extent = std::dynamic_extent>
size_type wpi::rotated_span< T, Extent >::offset ( ) const
inlineconstexprnoexcept

◆ operator=()

template<typename T , size_t Extent = std::dynamic_extent>
rotated_span & wpi::rotated_span< T, Extent >::operator= ( rotated_span< T, Extent > && )
constexprdefaultnoexcept

◆ operator[]()

template<typename T , size_t Extent = std::dynamic_extent>
reference wpi::rotated_span< T, Extent >::operator[] ( size_type idx) const
inlinenodiscardconstexprnoexcept

◆ rbegin()

template<typename T , size_t Extent = std::dynamic_extent>
reverse_iterator wpi::rotated_span< T, Extent >::rbegin ( ) const
inlinenodiscardconstexprnoexcept

◆ rend()

template<typename T , size_t Extent = std::dynamic_extent>
reverse_iterator wpi::rotated_span< T, Extent >::rend ( ) const
inlinenodiscardconstexprnoexcept

◆ rotate()

template<typename T , size_t Extent = std::dynamic_extent>
rotated_span wpi::rotated_span< T, Extent >::rotate ( int amt) const
inlinenodiscardconstexprnoexcept

◆ size()

template<typename T , size_t Extent = std::dynamic_extent>
size_type wpi::rotated_span< T, Extent >::size ( ) const
inlineconstexprnoexcept

◆ size_bytes()

template<typename T , size_t Extent = std::dynamic_extent>
size_type wpi::rotated_span< T, Extent >::size_bytes ( ) const
inlineconstexprnoexcept

Member Data Documentation

◆ count

template<typename T , size_t Extent = std::dynamic_extent>
size_type wpi::rotated_span< T, Extent >::count

◆ extent

template<typename T , size_t Extent = std::dynamic_extent>
size_t wpi::rotated_span< T, Extent >::extent = Extent
staticconstexpr

◆ last

template<typename T , size_t Extent = std::dynamic_extent>
size_type int std::sized_sentinel_for< It > End constexpr End wpi::rotated_span< T, Extent >::last

◆ m_offset

template<typename T , size_t Extent = std::dynamic_extent>
OExtent int rotation wpi::rotated_span< T, Extent >::m_offset
Initial value:
{MakeOffset(other.m_data.size(), other.m_offset + rotation)} {}
template <typename OType, size_t OExtent>
requires(Extent == std::dynamic_extent || OExtent == std::dynamic_extent ||
Extent == OExtent)
constexpr explicit(extent != std::dynamic_extent &&
OExtent == std::dynamic_extent) rotated_span(
: m_data{other.m_data}
This is a simple rotated span view.
Definition rotated_span.h:37
constexpr rotated_span() noexcept=default
constexpr OExtent int rotation noexcept
Definition rotated_span.h:98
constexpr size_type int rotation
Definition rotated_span.h:63
static constexpr size_t extent
Definition rotated_span.h:49

◆ noexcept

template<typename T , size_t Extent = std::dynamic_extent>
OExtent int rotation wpi::rotated_span< T, Extent >::noexcept

◆ other

template<typename T , size_t Extent = std::dynamic_extent>
OExtent& wpi::rotated_span< T, Extent >::other

◆ rotation [1/2]

template<typename T , size_t Extent = std::dynamic_extent>
size_type int wpi::rotated_span< T, Extent >::rotation
Initial value:
= 0) noexcept
: rotated_span{std::span<T, Extent>{first, count}, rotation} {}
template <std::contiguous_iterator It
constexpr size_type count
Definition rotated_span.h:63
Implement std::hash so that hash_code can be used in STL containers.
Definition PointerIntPair.h:280

◆ rotation [2/2]

template<typename T , size_t Extent = std::dynamic_extent>
size_type int std::sized_sentinel_for< It > End constexpr End int wpi::rotated_span< T, Extent >::rotation
Initial value:
= 0) noexcept(noexcept(std::span<T, Extent>{
first, last}))
: rotated_span{std::span<T, Extent>{first, last}, rotation} {}
template <size_t ArrayExtent>
requires(Extent == std::dynamic_extent || ArrayExtent == Extent)
constexpr rotated_span(
std::type_identity_t<element_type> (&arr)[ArrayExtent],
int rotation = 0) noexcept
: rotated_span{std::span<T, Extent>{arr}, rotation} {}
template <typename Tp
constexpr size_type int std::sized_sentinel_for< It > End constexpr End last
Definition rotated_span.h:69

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