CppWAMP
C++11 client library for the WAMP protocol
Visitors

Concepts:

StaticVisitor

StaticVisitor is the C++ concept for a function object having operator() overloads that can take any of wamp::Variant's bound types as a parameter.

Given:

  • visitor: a StaticVisitor instance, and,
  • bound: a reference to any of wamp::Variant's bound types (Null, Bool, Int, UInt, Real, String, Array, or Object),

then the following expressions must be valid:

Expression Effect
decltype(visitor)::ResultType Yields the common type returned by all operator() overloads
visitor(bound) Returns a value of type decltype(visitor)::ResultType

BinaryVisitor

BinaryVisitor is the C++ concept for a function object having operator() overloads that take two arguments of wamp::Variant's bound types. The overloads must handle every combination of Variant's bound types. To avoid combinatorial explosion, the operator() overloads are typically template functions that perform compile-time pattern matching, using type traits and SFINAE.

Given:

  • visitor: a BinaryVisitor instance, and,
  • left and right: two wamp::Variant bound type references,

then the following expressions must be valid:

Expression Effect
decltype(visitor)::ResultType Yields the common type returned by all operator() overloads
vis(left, right) Returns a value of type decltype(visitor)::ResultType

where left and right are references to any of Variant's bound types (Null, Bool, Int, UInt, Real, String, Array, or Object).

OperandVisitor

OperandVisitor is the C++ concept for a function object having operator() overloads that take two arguments. This concept is required for the applyWithOperand function. The operator() overloads must handle any of wamp::Variant's bound types as their first argument. They must also handle a value or reference of type O for their second argument, where O is the type of the operand argument passed to applyWithOperand.

Given:

  • visitor: an OperandVisitor instance,
  • bound: a reference to any of wamp::Variant's bound types, and, (Null, Bool, Int, UInt, Real, String, Array, or Object)
  • operand: an operand l-value or r-value reference,

then the following expressions must be valid:

Expression Effect
decltype(visitor)::ResultType Yields the common type returned by all operator() overloads
visitor(bound, operand) Returns a value of type decltype(visitor)::ResultType