Demo Visitor - GerdHirsch/Cpp-VisitorFrameworkCyclicAcyclic GitHub Wiki

The used Visitor for the NonVisitableExample.

class DemoVisitor : public Repository::visits<typelist>{
public:
    std::string toString() const override { return "DemoVisitor"; }

void visit(NonVisitable& v) {
    std::cout << toString() << "::visit(" << VisitorFramework::toString(v) << ")" << std::endl;
}
void visit(int& v) {
    std::cout << toString() << "::visit(" << VisitorFramework::toString(v) << ")" << std::endl;
}
void visit(double& v) {
    std::cout << toString() << "::visit(" << VisitorFramework::toString(v) << ")" << std::endl;
}

};

Note: VisitorFramework::toString(v) calls either v.toString() or prints the type-info name with typeid(v).name().

⚠️ **GitHub.com Fallback** ⚠️