matador::any_visitor Class Reference

An any visitor class. More...

#include <any_visitor.hpp>

Public Types

using function = std::function< void(matador::any &)>
 

Public Member Functions

template<typename T >
void register_visitor (const std::function< void(T &)> &f)
 Register a callback function for a concrete type.
 
bool visit (matador::any &x)
 Applies the visitor pattern on an any object.
 

Detailed Description

An any visitor class.

This class can be used to implement the visitor pattern for the any type class. Register function for as many types you need. Then call visit to apply the visitor pattern.

Member Typedef Documentation

◆ function

using matador::any_visitor::function = std::function<void(matador::any&)>

Shortcut for the visitor callback function

Member Function Documentation

◆ register_visitor()

template<typename T >
void matador::any_visitor::register_visitor ( const std::function< void(T &)> &  f)
inline

Register a callback function for a concrete type.

Template Parameters
TType of the argument passed into the function
Parameters
fThe callback function

◆ visit()

bool matador::any_visitor::visit ( matador::any x)
inline

Applies the visitor pattern on an any object.

Parameters
xThe any object the pattern should be applied on
Returns
Returns true if a function could be applied.

The documentation for this class was generated from the following file:
  • matador/utils/any_visitor.hpp