root value to visit
struct providing templated visit method accepting single argument which will be a pointer to visited element
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);
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.