visitValue

Recursively iterates over value fields and calls visitor.visit for each one of those. visitor.visit is expected to be a template with the following signature:

bool visit ( T ) ( T* value )

The return value indicates whether the value should be recursed into or not.

void
visitValue
(
T
Visitor
)
(
ref T value
,
ref Visitor visitor
)

Parameters

value T

root value to visit

visitor Visitor

struct providing templated visit method accepting single argument which will be a pointer to visited element

Examples

struct SumIntegersVisitor
{
    /// Visitor can have any internal state it may need
    long sum;

    /// Returns: 'true' if recursion shall continue for this type
    bool visit ( T ) ( T* value )
    {
        static if (isIntegerType!(T))
            sum += *value;

        return true;
    }
}

SumIntegersVisitor visitor;
visitValue(some_value, visitor);

Meta