Caffe2 - C++ API
A deep learning, cross platform ML framework
Public Types
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 reverse_iterator = std::reverse_iterator< iterator >
 

Public Member Functions

Constructors
constexpr ArrayRef ()
 Construct an empty ArrayRef.
 
constexpr ArrayRef (const T &OneElt)
 Construct an ArrayRef from a single element.
 
constexpr ArrayRef (const T *data, size_t length)
 Construct an ArrayRef from a pointer and length.
 
constexpr ArrayRef (const T *begin, const T *end)
 Construct an ArrayRef from a range.
 
template<typename U >
 ArrayRef (const SmallVectorTemplateCommon< T, U > &Vec)
 Construct an ArrayRef from a SmallVector. More...
 
template<typename A >
 ArrayRef (const std::vector< T, A > &Vec)
 Construct an ArrayRef from a std::vector.
 
template<size_t N>
constexpr ArrayRef (const std::array< T, N > &Arr)
 Construct an ArrayRef from a std::array.
 
template<size_t N>
constexpr ArrayRef (const T(&Arr)[N])
 Construct an ArrayRef from a C array.
 
constexpr ArrayRef (const std::initializer_list< T > &Vec)
 Construct an ArrayRef from a std::initializer_list.
 
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.
 
constexpr const Tdata () const
 
constexpr size_t size () const
 size - Get the array size.
 
AT_CPP14_CONSTEXPR const Tfront () const
 front - Get the first element.
 
AT_CPP14_CONSTEXPR const Tback () const
 back - Get the last element.
 
constexpr bool equals (ArrayRef RHS) const
 equals - Check for element-wise equality.
 
AT_CPP14_CONSTEXPR ArrayRef< Tslice (size_t N, size_t M) const
 slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array. More...
 
constexpr ArrayRef< Tslice (size_t N) const
 slice(n) - Chop off the first N elements of the array.
 
Operator Overloads
constexpr const Toperator[] (size_t Index) const
 
AT_CPP14_CONSTEXPR const Tat (size_t Index) const
 Vector compatibility.
 
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< Tvec () 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.

Definition at line 41 of file ArrayRef.h.

Constructor & Destructor Documentation

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.

Definition at line 79 of file ArrayRef.h.

Member Function Documentation

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.

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.

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

slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.

Definition at line 161 of file ArrayRef.h.


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