array_ref.h#

namespace ONNX_LIGHT_NAMESPACE
template<typename T>
class ArrayRef#
#include <array_ref.h>

Represents a non-owning view over a contiguous sequence of elements.

The referenced storage must outlive the ArrayRef instance.

Public Types

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

Public Functions

inline ArrayRef()#

Constructs an empty reference.

inline ArrayRef(const T &one_elt)#

Constructs a single-element reference.

inline ArrayRef(const T *data, size_t length)#

Constructs a reference from a pointer and explicit length.

inline ArrayRef(const T *begin, const T *end)#

Constructs a reference from a half-open pointer range [begin, end).

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

Constructs an ArrayRef from a vector.

template<size_t N>
inline constexpr ArrayRef(const std::array<T, N> &arr)#

Constructs an ArrayRef from a fixed-size std::array.

template<size_t N>
inline constexpr ArrayRef(const T (&arr)[N])#

Constructs an ArrayRef from a C array.

inline ArrayRef(const std::initializer_list<T> &vec)#

Constructs an ArrayRef from an initializer list.

inline iterator begin() const#

Returns an iterator to the beginning.

inline iterator end() const#

Returns an iterator to the end.

inline reverse_iterator rbegin() const#

Returns a reverse iterator to the beginning of the reversed range.

inline reverse_iterator rend() const#

Returns a reverse iterator to the end of the reversed range.

inline bool empty() const#

Returns true if the reference is empty.

inline const T *data() const#

Returns the underlying data pointer.

inline size_t size() const#

Returns the number of elements.

inline const T &front() const#

Returns the first element. Precondition: the reference is non-empty.

inline const T &back() const#

Returns the last element. Precondition: the reference is non-empty.

inline bool equals(ArrayRef rhs) const#

Returns true if both references contain the same values.

inline ArrayRef<T> slice(size_t n, size_t m) const#

Returns a sub-reference starting at n with length m. Precondition: n + m <= size().

inline ArrayRef<T> slice(size_t n) const#

Returns a sub-reference starting at n until the end. Precondition: n <= size().

inline const T &operator[](size_t index) const#

Returns the element at index. Precondition: index is in range.

inline const T &at(size_t index) const#

Returns the element at index. Precondition: index is in range.

template<typename U>
std::enable_if_t<std::is_same_v<U, T>, ArrayRef<T>> &operator=(U &&temporary) = delete#
template<typename U>
std::enable_if_t<std::is_same_v<U, T>, ArrayRef<T>> &operator=(std::initializer_list<U>) = delete#
inline std::vector<T> vec() const#

Returns a vector copy of the referenced elements.

inline operator std::vector<T>() const#

Converts to a vector copy of the referenced elements.

Private Members

const T *data_#
size_type length_#