Main Content

matlab::data::apply_visitor

Call Visitor class on arrays

Description

auto apply_visitor(Array a, V visitor) dispatch to visitor class operations based on array type.

Use apply_visitor to pass in an instance of Array or one of its subclasses and a visitor functor, and invoke the operator() method, which must be defined in the user-defined functor, with the appropriate concrete array type.

Include

Namespace:

matlab::data
IncludeArrayVisitors.hpp

Parameters

matlab::data::Array a&&

The matlab::data::Array to operate on with the visitor class, passed:

  • by value

  • by const lvalue ref

  • by rvalue ref

  • by nonconst lvalue ref

    To modify the original array, pass it by rvalue ref into the operator() method and return the modified array. Then the calling code should move the returned array into the old array. Due to copy-on-write behavior, passing by nonconst lvalue ref does not modify the original array.

visitor class V&&

The user-supplied visitor object, passed:

  • by value

  • by const lvalue ref

  • by rvalue ref

  • by nonconst lvalue ref

Return Value

auto

Outputs returned by the visitor.

Version History

Introduced in R2017b