A mutable reference to consecutive elements in memory.

Synopsis

Declared in <llvm/ADT/ArrayRef.h>

template<typename T>
class [[nodiscard]] MutableArrayRef
    : public ArrayRef<T>

Description

Represent a mutable 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 and modify 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 MutableArrayRef. For this reason, it is not in general safe to store a MutableArrayRef.

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

Base Classes

Name

Description

ArrayRef<T>

A constant reference to consecutive elements in memory.

Type Aliases

Name

Description

const_iterator

Const iterator over the referenced array elements.

const_pointer

Pointer to a const element.

const_reference

Const reference to an element.

const_reverse_iterator

Const reverse iterator over the referenced array elements.

difference_type

Signed type used to express the distance between iterators.

iterator

Iterator over the referenced array elements.

pointer

Mutable pointer to an element.

reference

Mutable reference to an element.

reverse_iterator

Reverse iterator over the referenced array elements.

size_type

Unsigned type used to express the size of the array.

value_type

Element type stored in the referenced array.

Member Functions

Name

Description

MutableArrayRef [constructor]

Constructors

operator=

Disallow accidental assignment from a temporary.

back

Get the last element.

begin

Iterator to the first mutable element.

consume_back

Returns the last element and drops it from ArrayRef.

consume_front

Returns the first element and drops it from ArrayRef.

copy

Allocate a mutable copy in A and return a reference to it.

data

Return a mutable pointer to the start of the array.

drop_back

Drop the last N elements of the array.

drop_front

Drop the first N elements of the array.

drop_until

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

drop_while

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

empty

Check if the array is empty.

end

Iterator one past the last mutable element.

equals

Check for element‐wise equality.

front

Get the first element.

operator[]

Return a mutable reference to the element at Index.

rbegin

Return a reverse iterator to the last mutable element.

rend

Return a reverse iterator to the element before the first element.

size

Get the array size.

slice

slice overloads

take_back

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

take_front

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

take_until

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

take_while

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

vec

Copy the referenced elements into a new std::vector.

operator std::vector<T>

Convert this ArrayRef into a std::vector copy of its elements.

Deduction Guides

Name

Description

MutableArrayRef<T>

@{ Deduction guide to construct a MutableArrayRef from a single element

MutableArrayRef<T>

Deduction guide to construct a MutableArrayRef from a SmallVector.

MutableArrayRef<T>

Deduction guide to construct a MutableArrayRef from a std::vector.

MutableArrayRef<T>

Deduction guide to construct a MutableArrayRef from a fixed‐size SmallVector.

MutableArrayRef<T>

Deduction guide to construct a MutableArrayRef from a std::array.

MutableArrayRef<T>

Deduction guide to construct a MutableArrayRef from a C array.

MutableArrayRef<T>

Deduction guide to construct a MutableArrayRef from a pointer and length.

Non-Member Functions

Name

Description

performOptimizedStructLayout

Compute a layout for a struct containing the given fields, making a best‐effort attempt to minimize the amount of space required.

codeview::serialize_array

Build an array serialization helper whose length comes from Func.

codeview::serialize_array_tail

Build a helper that deserializes the remaining stream as an array of T.

lto::findThinLTOModule

Returns the BitcodeModule that is ThinLTO.

orc::writeMachOStruct

Write a MachO structure into a buffer at the given offset.

wholeprogramdevirt::setAfterReturnValues

Store each target's RetVal at allocation offset AllocAfter.

wholeprogramdevirt::setBeforeReturnValues

Store each target's RetVal at allocation offset AllocBefore.

Return Value

Note

The return value should not be discarded.

Created with MrDocs