mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Data Structures | Namespaces | Macros | Functions
Visitor.hpp File Reference
#include <mutable/mutable-config.hpp>
#include <mutable/util/crtp.hpp>
#include <mutable/util/fn.hpp>
#include <mutable/util/macro.hpp>
#include <mutable/util/some.hpp>
#include <mutable/util/tag.hpp>
#include <optional>
#include <type_traits>
Include dependency graph for Visitor.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  m::visit_stop_recursion
 Exception class which can be thrown to stop entire recursion in visitors. More...
 
struct  m::visit_skip_subtree
 Exception class which can be thrown to skip recursion of the subtree in pre-order visitors. More...
 
struct  m::detail::Visitor< ConcreteVisitor, Base >
 Visitor base class, using CRTP. More...
 
struct  m::detail::visitor_method_helper< ConcreteVisitor, Base, Class, Classes >
 This helper class creates a single definition of virtual void operator()(...) for one subtype in a class hierarchy, and then recursively inherits from an instantiation of that same helper class for the next subtype in the hierarchy. More...
 
struct  m::detail::visitor_method_helper< ConcreteVisitor, Base, Class >
 This specialization marks the end of the class hierarchy. More...
 
struct  m::detail::VisitorImpl< ConcreteVisitor, Base, Hierarchy >
 A helper class to define virtual visit methods for all classes in. More...
 
struct  m::detail::stl_visit_helper< Callable, ResultType, Visitor, Class, Classes >
 This helper class creates a single override of operator() for one subtype in a class hierarchy, and then recursively inherits from an instantiation of that same helper class for the next subtype in the hierarchy. More...
 
struct  m::detail::stl_visit_helper< Callable, ResultType, Visitor, Class >
 This specialization marks the end of the class hierarchy. More...
 

Namespaces

namespace  m
 

‍mutable namespace


 
namespace  m::detail
 

Macros

#define M_MAKE_STL_VISITABLE(VISITOR, BASE_CLASS, CLASS_LIST)
 Defines a function visit() to make the class hierarchy STL-style visitable with VISITOR.
 
#define M_DECLARE_VISITOR(VISITOR_NAME, BASE_CLASS, CLASS_LIST)
 Defines a visitor VISITOR_NAME to visit the class hierarchy rooted in BASE_CLASS and with subclasses CLASS_LIST.
 

Functions

template<typename Callable , typename Visitor , typename Base , typename... Hierarchy>
auto m::visit (Callable &&callable, Base &obj, m::tag< Callable > &&=m::tag< Callable >())
 Generic implementation to visit a class hierarchy, with similar syntax as std::visit.
 

Macro Definition Documentation

◆ M_DECLARE_VISITOR

#define M_DECLARE_VISITOR (   VISITOR_NAME,
  BASE_CLASS,
  CLASS_LIST 
)
Value:
struct VISITOR_NAME : m::detail::VisitorImpl<VISITOR_NAME, BASE_CLASS CLASS_LIST(M_COMMA_PRE)> { \
using super = m::detail::VisitorImpl<VISITOR_NAME, BASE_CLASS CLASS_LIST(M_COMMA_PRE)>; \
using super::operator(); \
}; \
M_MAKE_STL_VISITABLE(VISITOR_NAME, BASE_CLASS, CLASS_LIST)
#define M_COMMA_PRE(X)
Definition: macro.hpp:24
A helper class to define virtual visit methods for all classes in.
Definition: Visitor.hpp:81

Defines a visitor VISITOR_NAME to visit the class hierarchy rooted in BASE_CLASS and with subclasses CLASS_LIST.

Also defines a function visit() to make the class hierarchy STL-style visitable with VISITOR_NAME.

All this must be done with a macro, such that the definition of the visitor class and the visit() function reside in the current namespace (as chosen by the user of this macro). This enables argument-dependent lookup (ADL).

Definition at line 181 of file Visitor.hpp.

◆ M_MAKE_STL_VISITABLE

#define M_MAKE_STL_VISITABLE (   VISITOR,
  BASE_CLASS,
  CLASS_LIST 
)
Value:
template<typename Callable> \
auto visit(Callable &&callable, BASE_CLASS &obj, m::tag<VISITOR>&& = m::tag<VISITOR>()) { \
return m::visit<Callable, VISITOR, BASE_CLASS CLASS_LIST(M_COMMA_PRE)>(std::forward<Callable>(callable), obj); \
}
Definition: tag.hpp:8

Defines a function visit() to make the class hierarchy STL-style visitable with VISITOR.

All this must be done with a macro, such that the definition of the visitor class and the visit() function reside in the current namespace (as chosen by the user of this macro). This enables argument-dependent lookup (ADL).

Definition at line 166 of file Visitor.hpp.