Template Class ArrayRef¶
Defined in File ArrayRef.hpp
Inheritance Relationships¶
Derived Type¶
public ams::MutableArrayRef< T >(Template Class MutableArrayRef)
Class Documentation¶
-
template<typename T>
class ArrayRef¶ 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.
Subclassed by ams::MutableArrayRef< T >
Constructors
-
inline constexpr ArrayRef(const T *data, size_t length)¶
Construct an ArrayRef from a pointer and length.
-
template<typename U>
inline ArrayRef(const SmallVectorTemplateCommon<T, U> &Vec)¶ Construct an ArrayRef from a SmallVector. This is templated in order to avoid instantiating SmallVectorTemplateCommon<T> whenever we copy-construct an ArrayRef.
-
template<typename A>
inline ArrayRef(const std::vector<T, A> &Vec)¶ Construct an ArrayRef from a std::vector.
-
template<size_t N>
inline constexpr ArrayRef(const std::array<T, N> &Arr)¶ Construct an ArrayRef from a std::array.
-
template<size_t N>
inline constexpr ArrayRef(const T (&Arr)[N])¶ Construct an ArrayRef from a C array.
-
inline constexpr ArrayRef(const std::initializer_list<T> &Vec)¶
Construct an ArrayRef from a std::initializer_list.
-
template<typename U>
inline ArrayRef(const ArrayRef<U*> &A, std::enable_if_t<std::is_convertible<U*const*, T const*>::value>* = nullptr)¶ Construct an ArrayRef<const T*> from ArrayRef<T*>. This uses SFINAE to ensure that only ArrayRefs of pointers can be converted.
-
template<typename U, typename DummyT>
inline ArrayRef(const SmallVectorTemplateCommon<U*, DummyT> &Vec, std::enable_if_t<std::is_convertible<U*const*, T const*>::value>* = nullptr)¶ Construct an ArrayRef<const T*> from a SmallVector<T*>. This is templated in order to avoid instantiating SmallVectorTemplateCommon<T> whenever we copy-construct an ArrayRef.
Simple Operations
-
inline reverse_iterator rbegin() const¶
-
inline reverse_iterator rend() const¶
-
inline bool empty() const¶
empty - Check if the array is empty.
-
inline size_t size() const¶
size - Get the array size.
-
template<typename Allocator>
inline MutableArrayRef<T> copy(Allocator &A)¶
-
inline ArrayRef<T> slice(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.
-
template<class PredicateT>
inline ArrayRef<T> drop_while(PredicateT Pred) const¶ Return a copy of *this with the first N elements satisfying the given predicate removed.
-
template<class PredicateT>
inline ArrayRef<T> drop_until(PredicateT Pred) const¶ Return a copy of *this with the first N elements not satisfying the given predicate removed.
-
inline ArrayRef<T> take_front(size_t N = 1) const¶
Return a copy of *this with only the first
Nelements.
-
inline ArrayRef<T> take_back(size_t N = 1) const¶
Return a copy of *this with only the last
Nelements.
-
template<class PredicateT>
inline ArrayRef<T> take_while(PredicateT Pred) const¶ Return the first N elements of this Array that satisfy the given predicate.
-
template<class PredicateT>
inline ArrayRef<T> take_until(PredicateT Pred) const¶ Return the first N elements of this Array that don’t satisfy the given predicate.
Operator Overloads
Public Types
-
using pointer = value_type*¶
-
using const_pointer = const value_type*¶
-
using reference = value_type&¶
-
using const_reference = const value_type&¶
-
using iterator = const_pointer¶
-
using const_iterator = const_pointer¶
-
using const_reverse_iterator = std::reverse_iterator<const_iterator>¶
-
using size_type = size_t¶
-
using difference_type = ptrdiff_t¶
-
inline constexpr ArrayRef(const T *data, size_t length)¶