matlab::data::Reference - Templated C++ class to get references to Array

        elements - MATLAB ([original](https://in.mathworks.com/help/matlab/apiref/matlab.data.reference.html)) ([raw](?raw))

Main Content

Templated C++ class to get references to Array elements

Description

A Reference object is a reference to an element of anArray without making a copy. A Reference is:

Class Details

Namespace: matlab::data
Include: Reference.hpp

Template Parameters

T Type of element referred to, specified as: ArrayStructEnumerationMATLABStringAll std::complex types

Constructors

Copy Constructor

Reference(const Reference<T>& rhs)

Parameters

const Reference& rhs Value to copy.

Copy Assignment Operators

Reference<T>& operator=(const Reference<T>& rhs)

Parameters

const Reference& rhs Value to copy.

Returns

Reference& Updated instance.

Move Assignment Operators

Reference<T>& operator=(Reference<T>&& rhs)

Parameters

Reference&& rhs Value to move.

Returns

Reference& Updated instance.

Move Constructors

Reference(Reference<T>&& rhs)

Description

Moves contents of a Reference object to a new instance.

Parameters

Reference&& rhs Value to move.

Other Operators

operator=

Reference<T>& operator=(T rhs)

Reference<T>& operator=(std::string rhs)

Reference<T>& operator=(String rhs)

Parameters

T rhs Value to assign. The indexed array must be non-const.
std::string rhs String to assign. The array must be non-const and allow strings to be assigned.
String rhs String to assign to StringArray. The indexed array must be non-const.

Returns

Reference& Updated instance.

operator<<

std::ostream& operator <<(std::ostream& os, Reference<T> const& rhs)

Parameters

| std::ostream& os | | | ----------------------- | | | Reference const& rhs | |

operator T()

Description

Cast to element from the array.

Returns

T Shared copy of element from array.

operator std::string()

operator std::string() const

Description

Casts array to std::string, making a copy of thestd::string. This operator is valid only for types that can be cast to a std::string.

Throws

matlab::data::NonAsciiCharInInputDataException Input is std::string and contains non-ASCII characters.
std::runtime_error MATLABString is missing.

Free Functions

operator==

inline bool operator ==(Reference<MATLABString> const& lhs, std::string const& rhs)

inline bool operator ==(std::string const& lhs, Reference<MATLABString> const& rhs)

inline bool operator ==(Reference<MATLABString> const& lhs, String const& rhs)

inline bool operator ==(String const& lhs, Reference<MATLABString> const& rhs)

inline bool operator ==(Reference<MATLABString> const& lhs, MATLABString const& rhs)

inline bool operator ==(MATLABString const& lhs, Reference<MATLABString> const& rhs)

inline bool operator ==(Reference<MATLABString> const& lhs, Reference<MATLABString> const& rhs)

template<typename T> bool operator ==(Reference<T> const& lhs, T const& rhs)

template<typename T> bool operator ==(T const& lhs, Reference<T> const& rhs)

template<typename T> bool operator ==(Reference<T> const& lhs, Reference<T> const& rhs)

Parameters

Reference const& lhs std::string const& rhs Values to compare.
std::string const& lhs Reference const& rhs
Reference const& lhs String const& rhs
String const& lhs Reference const& rhs
Reference const& lhs MATLABString const& rhs
MATLABString const& lhs Reference const& rhs
Reference const& lhs Reference const& rhs
Reference const& lhs T const& rhs
T const& lhs Reference const& rhs
Reference const& lhs Reference const& rhs

Returns

bool Returns true if values are equal.

Throws

std::runtime_error Cannot compare argument toMATLABString.

Version History

Introduced in R2017b

See Also