Skip to content

Instantly share code, notes, and snippets.

Nicuvëo nicuveo

Block or report user

Report or block nicuveo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nicuveo
nicuveo / 01_README.md
Last active Aug 29, 2015
Extending library visitor for user-defined types with macros (example)
View 01_README.md

While the previous gist documented my attempt at finding a working solution, this one provides a small working example.

Here, the library code declares classes A and B both inheriting form a base class Base. A Visitor is introduced, and both A and B have a apply method that calls the appropriate visitor method.

The client introduces a new class C that also inherits from base, and which is able to use a Visitor-derived class on any Base* pointer, be it a A, a B or a C under the hood.

@nicuveo
nicuveo / 00_README.md
Last active Aug 29, 2015
Extending library visitor for user-defined types with macros
View 00_README.md

Summary

The code in this gist tries to find a way to have pseudo "multi methods" in C++ by extending a visitor interface, hence the title: extending library visitor for user-defined types with macros. The idea is this: you want to implement the Visitor pattern over a class hierarchy defined in a library. But users of the library might have their own classes, extending the hierarchy, forcing your visitor to know about them. My proposal: a small macros that extend the visitor

You can’t perform that action at this time.