Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Function template visit

trial::dynamic::visit — Mutable visitation.

Synopsis

// In header: <boost/libs/trial.protocol/include/trial/dynamic/algorithm/visit.hpp>


template<typename Visitor, template< typename > class Allocator> 
  auto visit(Visitor && visitor, basic_variable< Allocator > & variable);

Description

Invokes the call operator on the visitor whose type matches the stored type of the dynamic variable. The type is resolved using the normal rules for C++ function overloading. All call operators must use the same return type.

struct visitor
{
  // Matches any stored type; returns nothing.
  template <typename T> void operator()(T);
};

dynamic::variable data = 1;
assert(data.same<int>());
dynamic::visit(visitor{}, data); // Invokes visitor.operator()(int)

Parameters:

variable

Non-const dynamic variable.

visitor

Visitor object.

Returns:

Return type of Visitor::operator()(nullable).


PrevUpHomeNext