Make Visitable - GerdHirsch/Cpp-VisitorFrameworkCyclicAcyclic GitHub Wiki

Extend your classes non invasiv with the property "Visitable". All what you need is a Repository with your classes and a Factory<Repository> to do the following:

Visitables visitables;

NonVisitable nv; 
auto pU = std::make_unique<NonVisitable>();
auto pS = std::make_shared<int>(42);

DemoVisitor visitor;

// by Reference
visitables.push_back(Factory::makeVisitable(nv));
// by Value
visitables.push_back(Factory::makeVisitable(NonVisitable()));
visitables.push_back(Factory::makeVisitable(3.14));
// by unique_ptr
visitables.push_back(Factory::makeVisitable(std::move(pU) ));
visitables.push_back(Factory::makeVisitable(std::make_unique<NonVisitable>() ));
// by weak_ptr
visitables.push_back(Factory::makeVisitable(pS));


demoRunVisitor(visitor, visitables);

As you can see, it's possible to visit even build-in types with the framework.

you will find further information in DemoVisitorNonVisitable and in demoRunVisitor

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