class ArrayRef

Declaration

template <typename T>
class ArrayRef { /* full declaration omitted */ };

Description

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.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:42

Templates

T

Member Variables

private const T* Data = nullptr
The start of the array, in an external buffer.
private llvm::ArrayRef::size_type Length = 0
The number of elements.

Method Overview

  • public template <typename U, typename DummyT> ArrayRef<T>(const SmallVectorTemplateCommon<U *, DummyT> & Vec, std::enable_if_t<std::is_convertible<U *const *, const T *>::value> * = nullptr)
  • public ArrayRef<T>()
  • public template <typename U> ArrayRef<T>(const SmallVectorTemplateCommon<T, U> & Vec)
  • public template <typename A> ArrayRef<T>(const std::vector<T, A> & Vec)
  • public template <size_t N>constexpr ArrayRef<T>(const std::array<T, N> & Arr)
  • public template <size_t N>constexpr ArrayRef<T>(const T (&)[N] Arr)
  • public template <typename U> ArrayRef<T>(const ArrayRef<U *> & A, std::enable_if_t<std::is_convertible<U *const *, const T *>::value> * = nullptr)
  • public template <typename U, typename A> ArrayRef<T>(const std::vector<U *, A> & Vec, std::enable_if_t<std::is_convertible<U *const *, const T *>::value> * = nullptr)
  • public ArrayRef<T>(const std::initializer_list<T> & Vec)
  • public ArrayRef<T>(const T * begin, const T * end)
  • public ArrayRef<T>(const T * data, size_t length)
  • public ArrayRef<T>(const T & OneElt)
  • public ArrayRef<T>(llvm::NoneType)
  • public const T & back() const
  • public llvm::ArrayRef::iterator begin() const
  • public template <typename Allocator>MutableArrayRef<T> copy(Allocator & A)
  • public const T * data() const
  • public ArrayRef<T> drop_back(size_t N = 1) const
  • public ArrayRef<T> drop_front(size_t N = 1) const
  • public template <class PredicateT>ArrayRef<T> drop_until(PredicateT Pred) const
  • public template <class PredicateT>ArrayRef<T> drop_while(PredicateT Pred) const
  • public bool empty() const
  • public llvm::ArrayRef::iterator end() const
  • public bool equals(ArrayRef<T> RHS) const
  • public const T & front() const
  • public std::vector<T> operator vector<type-parameter-0-0, allocator<type-parameter-0-0> >() const
  • public llvm::ArrayRef::reverse_iterator rbegin() const
  • public llvm::ArrayRef::reverse_iterator rend() const
  • public size_t size() const
  • public ArrayRef<T> slice(size_t N) const
  • public ArrayRef<T> slice(size_t N, size_t M) const
  • public ArrayRef<T> take_back(size_t N = 1) const
  • public ArrayRef<T> take_front(size_t N = 1) const
  • public template <class PredicateT>ArrayRef<T> take_until(PredicateT Pred) const
  • public template <class PredicateT>ArrayRef<T> take_while(PredicateT Pred) const
  • public std::vector<T> vec() const

Methods

template <typename U, typename DummyT>
ArrayRef<T>(
    const SmallVectorTemplateCommon<U*, DummyT>&
        Vec,
    std::enable_if_t<
        std::is_convertible<U* const*,
                            const T*>::value>* =
        nullptr)

Description

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.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:134

Templates

U
DummyT

Parameters

const SmallVectorTemplateCommon<U*, DummyT>& Vec
std::enable_if_t< std::is_convertible<U* const*, const T*>::value>* = nullptr

ArrayRef<T>()

Description

Construct an empty ArrayRef.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:68

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

Description

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

Declared at: llvm/include/llvm/ADT/ArrayRef.h:89

Templates

U

Parameters

const SmallVectorTemplateCommon<T, U>& Vec

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

Description

Construct an ArrayRef from a std::vector.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:95

Templates

A

Parameters

const std::vector<T, A>& Vec

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

Description

Construct an ArrayRef from a std::array

Declared at: llvm/include/llvm/ADT/ArrayRef.h:100

Templates

size_t N

Parameters

const std::array<T, N>& Arr

template <size_t N>
constexpr ArrayRef<T>(const T (&)[N] Arr)

Description

Construct an ArrayRef from a C array.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:105

Templates

size_t N

Parameters

const T (&)[N] Arr

template <typename U>
ArrayRef<T>(const ArrayRef<U*>& A,
            std::enable_if_t<std::is_convertible<
                U* const*,
                const T*>::value>* = nullptr)

Description

Construct an ArrayRef <const T*> from ArrayRef <T *>. This uses SFINAE to ensure that only ArrayRefs of pointers can be converted.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:125

Templates

U

Parameters

const ArrayRef<U*>& A
std::enable_if_t< std::is_convertible<U* const*, const T*>::value>* = nullptr

template <typename U, typename A>
ArrayRef<T>(const std::vector<U*, A>& Vec,
            std::enable_if_t<std::is_convertible<
                U* const*,
                const T*>::value>* = nullptr)

Description

Construct an ArrayRef <const T*> from std::vector <T *>. This uses SFINAE to ensure that only vectors of pointers can be converted.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:143

Templates

U
A

Parameters

const std::vector<U*, A>& Vec
std::enable_if_t< std::is_convertible<U* const*, const T*>::value>* = nullptr

ArrayRef<T>(const std::initializer_list<T>& Vec)

Declared at: llvm/include/llvm/ADT/ArrayRef.h:115

Parameters

const std::initializer_list<T>& Vec

ArrayRef<T>(const T* begin, const T* end)

Description

Construct an ArrayRef from a range.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:82

Parameters

const T* begin
const T* end

ArrayRef<T>(const T* data, size_t length)

Description

Construct an ArrayRef from a pointer and length.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:78

Parameters

const T* data
size_t length

ArrayRef<T>(const T& OneElt)

Description

Construct an ArrayRef from a single element.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:74

Parameters

const T& OneElt

ArrayRef<T>(llvm::NoneType)

Description

Construct an empty ArrayRef from None.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:71

Parameters

llvm::NoneType

const T& back() const

Description

back - Get the last element.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:173

llvm::ArrayRef::iterator begin() const

Description

@ } @ {

Declared at: llvm/include/llvm/ADT/ArrayRef.h:152

template <typename Allocator>
MutableArrayRef<T> copy(Allocator& A)

Declared at: llvm/include/llvm/ADT/ArrayRef.h:179

Templates

Allocator

Parameters

Allocator& A

const T* data() const

Declared at: llvm/include/llvm/ADT/ArrayRef.h:161

ArrayRef<T> drop_back(size_t N = 1) const

Description

Drop the last \p N elements of the array.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:209

Parameters

size_t N = 1

ArrayRef<T> drop_front(size_t N = 1) const

Description

Drop the first \p N elements of the array.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:203

Parameters

size_t N = 1

template <class PredicateT>
ArrayRef<T> drop_until(PredicateT Pred) const

Description

Return a copy of *this with the first N elements not satisfying the given predicate removed.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:222

Templates

PredicateT

Parameters

PredicateT Pred

template <class PredicateT>
ArrayRef<T> drop_while(PredicateT Pred) const

Description

Return a copy of *this with the first N elements satisfying the given predicate removed.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:216

Templates

PredicateT

Parameters

PredicateT Pred

bool empty() const

Description

empty - Check if the array is empty.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:159

llvm::ArrayRef::iterator end() const

Declared at: llvm/include/llvm/ADT/ArrayRef.h:153

bool equals(ArrayRef<T> RHS) const

Description

equals - Check for element-wise equality.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:186

Parameters

ArrayRef<T> RHS

const T& front() const

Description

front - Get the first element.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:167

std::vector<T> operator vector<
    type - parameter - 0 - 0,
    allocator<type - parameter - 0 - 0> >() const

Description

@ } @ {

Declared at: llvm/include/llvm/ADT/ArrayRef.h:286

llvm::ArrayRef::reverse_iterator rbegin() const

Declared at: llvm/include/llvm/ADT/ArrayRef.h:155

llvm::ArrayRef::reverse_iterator rend() const

Declared at: llvm/include/llvm/ADT/ArrayRef.h:156

size_t size() const

Description

size - Get the array size.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:164

ArrayRef<T> slice(size_t N) const

Description

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

Declared at: llvm/include/llvm/ADT/ArrayRef.h:200

Parameters

size_t N

ArrayRef<T> slice(size_t N, size_t M) const

Description

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

Declared at: llvm/include/llvm/ADT/ArrayRef.h:194

Parameters

size_t N
size_t M

ArrayRef<T> take_back(size_t N = 1) const

Description

Return a copy of *this with only the last \p N elements.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:234

Parameters

size_t N = 1

ArrayRef<T> take_front(size_t N = 1) const

Description

Return a copy of *this with only the first \p N elements.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:227

Parameters

size_t N = 1

template <class PredicateT>
ArrayRef<T> take_until(PredicateT Pred) const

Description

Return the first N elements of this Array that don't satisfy the given predicate.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:248

Templates

PredicateT

Parameters

PredicateT Pred

template <class PredicateT>
ArrayRef<T> take_while(PredicateT Pred) const

Description

Return the first N elements of this Array that satisfy the given predicate.

Declared at: llvm/include/llvm/ADT/ArrayRef.h:242

Templates

PredicateT

Parameters

PredicateT Pred

std::vector<T> vec() const

Description

@ } @ {

Declared at: llvm/include/llvm/ADT/ArrayRef.h:279