Main Content

matlab::data::Reference

C++ class to get reference toArray

Description

Use theReferenceclass to get a reference to anArrayelement 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.ArrayRefis defined as:

using ArrayRef = Reference;

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 thisArrayor one of the indices is out of range.

matlab::data::InvalidArrayTypeException

Arraytype not recognized.

getDimensions

ArrayDimensions getDimensions() const
Returns

ArrayDimensions

Arraydimensions vector.

Throws

matlab::data::NotEnoughIndicesProvidedException

Not enough indices provided.

matlab::data::InvalidArrayIndexException

Index provided is not valid for thisArrayor 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 thisArrayor 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 thisArrayor one of the indices is out of range.

Free Functions

getReadOnlyElements

template  Range getReadOnlyElements(const Reference& ref)
Description

得到一个包含o元素的范围f theArrayorReference. Iterators contained in the range areconst.

Parameters

const Reference& ref

Reference.

Returns

Range

Range containingbeginandenditerators for the elements of the inputReference.

Throws

matlab::data::InvalidArrayTypeException

Arraydoes not contain typeT.

getWritableElements

template  Range getWritableElements(Reference& ref)
Description

得到一个包含o元素的范围f theArrayorReference. Iterators contained in the range are non-const.

Parameters

Reference& ref

Reference.

Returns

Range

Range containingbeginandenditerators for the elements of the inputReference.

Throws

matlab::data::InvalidArrayTypeException

Arraydoes not contain typeT.

Version History

Introduced in R2017b

See Also