SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Member Functions | Public Attributes | List of all members
smtk::common::VisitorFunctor< Functor > Struct Template Reference

A template for accepting visitors with different return types. More...

#include <Visit.h>

Public Member Functions

 VisitorFunctor (Functor f)
 
template<class... Types>
auto invokeVisitor (Types &&... args) const -> typename std::enable_if< std::is_same< decltype(std::declval< Functor >()(args...)), Visit >::value, Visit >::type
 For functors that return a Visit enumerant, simply invoke them:
 
template<class... Types>
auto invokeVisitor (Types &&... args) const -> typename std::enable_if<!std::is_same< decltype(std::declval< Functor >()(args...)), Visit >::value, Visit >::type
 For functors that do not return a Visit enumerant (i.e., void), invoke them but always return Visit::Continue.
 
template<class... Types>
Visit operator() (Types &&... args) const
 The parenthesis operation simply forwards arguments to whichever method above is enabled.
 

Public Attributes

Functor m_functor
 

Detailed Description

template<typename Functor>
struct smtk::common::VisitorFunctor< Functor >

A template for accepting visitors with different return types.

Functions or class-methods that accept visitor functors used to iterate over a set of values may wish to allow visitors to terminate iteration early. However, in order to do so, visitors must return some value to indicate whether to continue or halt.

This templated functor class can be used to adapt functors that return no value to exhaustively iterate while also accepting functors that do provide cues on when to stop prematurely.

See UnitTestVisit in the testing subdirectory for a simple example.


The documentation for this struct was generated from the following file: