PyTorch
Loading...
Searching...
No Matches
Public Types | List of all members
c10::ArrayRef< T > Class Template Referencefinal

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory), i.e. More...

#include <ArrayRef.h>

Public Types

using iterator = const T *
 
using const_iterator = const T *
 
using size_type = size_t
 
using value_type = T
 
using reverse_iterator = std::reverse_iterator< iterator >
 

Public Member Functions

Constructors
constexpr ArrayRef ()
 Construct an empty ArrayRef. More...
 
constexpr ArrayRef (const T &OneElt)
 Construct an ArrayRef from a single element. More...
 
constexpr ArrayRef (const T *data, size_t length)
 Construct an ArrayRef from a pointer and length. More...
 
constexpr ArrayRef (const T *begin, const T *end)
 Construct an ArrayRef from a range. More...
 
template<typename U >
 ArrayRef (const SmallVectorTemplateCommon< T, U > &Vec)
 Construct an ArrayRef from a SmallVector. More...
 
template<typename Container >
 ArrayRef (const Container &container)
 
template<typename A >
 ArrayRef (const std::vector< T, A > &Vec)
 Construct an ArrayRef from a std::vector. More...
 
template<size_t N>
constexpr ArrayRef (const std::array< T, N > &Arr)
 Construct an ArrayRef from a std::array. More...
 
template<size_t N>
constexpr ArrayRef (const T(&Arr)[N])
 Construct an ArrayRef from a C array. More...
 
constexpr ArrayRef (const std::initializer_list< T > &Vec)
 Construct an ArrayRef from a std::initializer_list. More...
 
Simple Operations
constexpr iterator begin () const
 
constexpr iterator end () const
 
constexpr const_iterator cbegin () const
 
constexpr const_iterator cend () const
 
constexpr reverse_iterator rbegin () const
 
constexpr reverse_iterator rend () const
 
constexpr bool empty () const
 empty - Check if the array is empty. More...
 
constexpr const T * data () const
 
constexpr size_t size () const
 size - Get the array size. More...
 
constexpr const T & front () const
 front - Get the first element. More...
 
constexpr const T & back () const
 back - Get the last element. More...
 
constexpr bool equals (ArrayRef RHS) const
 equals - Check for element-wise equality. More...
 
constexpr ArrayRef< T > slice (size_t N, size_t M) const
 slice(n, m) - Take M elements of the array starting at element N More...
 
constexpr ArrayRef< T > slice (size_t N) const
 slice(n) - Chop off the first N elements of the array. More...
 
Operator Overloads
constexpr const T & operator[] (size_t Index) const
 
constexpr const T & at (size_t Index) const
 Vector compatibility. More...
 
template<typename U >
std::enable_if< std::is_same< U, T >::value, ArrayRef< T > >::type & operator= (U &&Temporary)=delete
 Disallow accidental assignment from a temporary. More...
 
template<typename U >
std::enable_if< std::is_same< U, T >::value, ArrayRef< T > >::type & operator= (std::initializer_list< U >)=delete
 Disallow accidental assignment from a temporary. More...
 
Expensive Operations
std::vector< T > vec () const
 

Detailed Description

template<typename T>
class c10::ArrayRef< T >

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory), i.e.

a start pointer and a length. It allows various APIs to take consecutive elements easily and conveniently.

This class does not own the underlying data, it is expected to be used in situations where the data resides in some other buffer, whose lifetime extends past that of the ArrayRef. For this reason, it is not in general safe to store an ArrayRef.

This is intended to be trivially copyable, so it should be passed by value.

Member Typedef Documentation

◆ const_iterator

template<typename T >
using c10::ArrayRef< T >::const_iterator = const T*

◆ iterator

template<typename T >
using c10::ArrayRef< T >::iterator = const T*

◆ reverse_iterator

template<typename T >
using c10::ArrayRef< T >::reverse_iterator = std::reverse_iterator<iterator>

◆ size_type

template<typename T >
using c10::ArrayRef< T >::size_type = size_t

◆ value_type

template<typename T >
using c10::ArrayRef< T >::value_type = T

Constructor & Destructor Documentation

◆ ArrayRef() [1/10]

template<typename T >
constexpr c10::ArrayRef< T >::ArrayRef ( )
inlineconstexpr

Construct an empty ArrayRef.

◆ ArrayRef() [2/10]

template<typename T >
constexpr c10::ArrayRef< T >::ArrayRef ( const T &  OneElt)
inlineconstexpr

Construct an ArrayRef from a single element.

◆ ArrayRef() [3/10]

template<typename T >
constexpr c10::ArrayRef< T >::ArrayRef ( const T *  data,
size_t  length 
)
inlineconstexpr

Construct an ArrayRef from a pointer and length.

◆ ArrayRef() [4/10]

template<typename T >
constexpr c10::ArrayRef< T >::ArrayRef ( const T *  begin,
const T *  end 
)
inlineconstexpr

Construct an ArrayRef from a range.

◆ ArrayRef() [5/10]

template<typename T >
template<typename U >
c10::ArrayRef< T >::ArrayRef ( const SmallVectorTemplateCommon< T, U > &  Vec)
inline

Construct an ArrayRef from a SmallVector.

This is templated in order to avoid instantiating SmallVectorTemplateCommon<T> whenever we copy-construct an ArrayRef.

◆ ArrayRef() [6/10]

template<typename T >
template<typename Container >
c10::ArrayRef< T >::ArrayRef ( const Container &  container)
inline

◆ ArrayRef() [7/10]

template<typename T >
template<typename A >
c10::ArrayRef< T >::ArrayRef ( const std::vector< T, A > &  Vec)
inline

Construct an ArrayRef from a std::vector.

◆ ArrayRef() [8/10]

template<typename T >
template<size_t N>
constexpr c10::ArrayRef< T >::ArrayRef ( const std::array< T, N > &  Arr)
inlineconstexpr

Construct an ArrayRef from a std::array.

◆ ArrayRef() [9/10]

template<typename T >
template<size_t N>
constexpr c10::ArrayRef< T >::ArrayRef ( const T(&)  Arr[N])
inlineconstexpr

Construct an ArrayRef from a C array.

◆ ArrayRef() [10/10]

template<typename T >
constexpr c10::ArrayRef< T >::ArrayRef ( const std::initializer_list< T > &  Vec)
inlineconstexpr

Construct an ArrayRef from a std::initializer_list.

Member Function Documentation

◆ at()

template<typename T >
constexpr const T & c10::ArrayRef< T >::at ( size_t  Index) const
inlineconstexpr

Vector compatibility.

◆ back()

template<typename T >
constexpr const T & c10::ArrayRef< T >::back ( ) const
inlineconstexpr

back - Get the last element.

◆ begin()

template<typename T >
constexpr iterator c10::ArrayRef< T >::begin ( ) const
inlineconstexpr

◆ cbegin()

template<typename T >
constexpr const_iterator c10::ArrayRef< T >::cbegin ( ) const
inlineconstexpr

◆ cend()

template<typename T >
constexpr const_iterator c10::ArrayRef< T >::cend ( ) const
inlineconstexpr

◆ data()

template<typename T >
constexpr const T * c10::ArrayRef< T >::data ( ) const
inlineconstexpr

◆ empty()

template<typename T >
constexpr bool c10::ArrayRef< T >::empty ( ) const
inlineconstexpr

empty - Check if the array is empty.

◆ end()

template<typename T >
constexpr iterator c10::ArrayRef< T >::end ( ) const
inlineconstexpr

◆ equals()

template<typename T >
constexpr bool c10::ArrayRef< T >::equals ( ArrayRef< T >  RHS) const
inlineconstexpr

equals - Check for element-wise equality.

◆ front()

template<typename T >
constexpr const T & c10::ArrayRef< T >::front ( ) const
inlineconstexpr

front - Get the first element.

◆ operator=() [1/2]

template<typename T >
template<typename U >
std::enable_if< std::is_same< U, T >::value, ArrayRef< T > >::type & c10::ArrayRef< T >::operator= ( std::initializer_list< U >  )
delete

Disallow accidental assignment from a temporary.

The declaration here is extra complicated so that "arrayRef = {}" continues to select the move assignment operator.

◆ operator=() [2/2]

template<typename T >
template<typename U >
std::enable_if< std::is_same< U, T >::value, ArrayRef< T > >::type & c10::ArrayRef< T >::operator= ( U &&  Temporary)
delete

Disallow accidental assignment from a temporary.

The declaration here is extra complicated so that "arrayRef = {}" continues to select the move assignment operator.

◆ operator[]()

template<typename T >
constexpr const T & c10::ArrayRef< T >::operator[] ( size_t  Index) const
inlineconstexpr

◆ rbegin()

template<typename T >
constexpr reverse_iterator c10::ArrayRef< T >::rbegin ( ) const
inlineconstexpr

◆ rend()

template<typename T >
constexpr reverse_iterator c10::ArrayRef< T >::rend ( ) const
inlineconstexpr

◆ size()

template<typename T >
constexpr size_t c10::ArrayRef< T >::size ( ) const
inlineconstexpr

size - Get the array size.

◆ slice() [1/2]

template<typename T >
constexpr ArrayRef< T > c10::ArrayRef< T >::slice ( size_t  N) const
inlineconstexpr

slice(n) - Chop off the first N elements of the array.

◆ slice() [2/2]

template<typename T >
constexpr ArrayRef< T > c10::ArrayRef< T >::slice ( size_t  N,
size_t  M 
) const
inlineconstexpr

slice(n, m) - Take M elements of the array starting at element N

◆ vec()

template<typename T >
std::vector< T > c10::ArrayRef< T >::vec ( ) const
inline

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