4 ms·
What is the actual problem? Is it multiple dispatch? I think some languages (Lisp may be one) handle it natively. Visitor is the only way I know of dealing wit
by criddell 8y ago
What is the actual problem? Is it multiple dispatch? I think some languages (Lisp may be one) handle it natively.
Visitor is the only way I know of dealing with it in C++. Once you do it enough, Visitor starts to feel like a pretty natural way to extend a class without modifying the class.
- jcelerier 8y ago> Visitor is the only way I know of dealing with it in C++. Once you do it enough, Visitor starts to feel like a pretty natural way to extend a class without modifying the class. Are you talking about traditonal OOP visitor pattern ? It's pretty terrible, when compared to std::variant ; imagine for instance that you want to have a way to draw the rect that contains a given shape without changing your shape class: https://godbolt.org/g/34KyMw https://godbolt.org/g/34KyMw
- criddell 8y agoIf your interface is that consistent, why not just make the bounding box drawing function a template? Visitor is nice when some kind of transformation needs to be applied to the visited objects.