Main Content

matlab::data::Reference<Array>

C++ class to get reference to Array

Description

Use the Reference<Array> class to get a reference to an Array element of a container object, such as a MATLAB® structure or cell array. The class is a base class for all reference types that refer to arrays and provides basic array information. ArrayRef is defined as:

using ArrayRef = Reference<Array>;

Class Details

Namespace:

matlab::data

Include:

ArrayReferenceExt.hpp

Member Functions

getType

ArrayType getType() const
Returns

ArrayType

Type of the array

Throws

matlab::data::NotEnoughIndicesProvidedException

Not enough indices provided.

matlab::data::InvalidArrayIndexException

Index provided is not valid for this Array or one of the indices is out of range.

matlab::data::InvalidArrayTypeException

Array type not recognized.

getDimensions

ArrayDimensions getDimensions() const
Returns

ArrayDimensions

Array dimensions vector.

Throws

matlab::data::NotEnoughIndicesProvidedException

Not enough indices provided.

matlab::data::InvalidArrayIndexException

Index provided is not valid for this Array or one of the indices is out of range.

getNumberOfElements

size_t getNumberOfElements() const
Returns

size_t

Number of elements in array.

Throws

matlab::data::NotEnoughIndicesProvidedException

Not enough indices provided.

matlab::data::InvalidArrayIndexException

Index provided is not valid for this Array or one of the indices is out of range.

isEmpty

bool isEmpty() const
Returns

bool

Returns true if array is empty, otherwise returns false.

Throws

matlab::data::NotEnoughIndicesProvidedException

Not enough indices provided.

matlab::data::InvalidArrayIndexException

Index provided is not valid for this Array or one of the indices is out of range.

Free Functions

getReadOnlyElements

template <typename T>
Range<TypedIterator, T const> getReadOnlyElements(const Reference<Array>& ref)
Description

Get a range containing the elements of the Array or Reference<Array>. Iterators contained in the range are const.

Parameters

const Reference<Array>& ref

Reference<Array>.

Returns

Range<TypedIterator, T const>

Range containing begin and end iterators for the elements of the input Reference<Array>.

Throws

matlab::data::InvalidArrayTypeException

Array does not contain type T.

getWritableElements

template <typename T>
Range<TypedIterator, T> getWritableElements(Reference<Array>& ref)
Description

Get a range containing the elements of the Array or Reference<Array>. Iterators contained in the range are non-const.

Parameters

Reference<Array>& ref

Reference<Array>.

Returns

Range<TypedIterator, T>

Range containing begin and end iterators for the elements of the input Reference<Array>.

Throws

matlab::data::InvalidArrayTypeException

Array does not contain type T.

Version History

Introduced in R2017b

See Also