Skip to main content

Questions tagged [visitor-pattern]

The visitor design pattern is a way of separating an algorithm from an object structure on which it operates. A practical result of this separation is the ability to add new operations to existing object structures without modifying those structures.

3 votes
1 answer
118 views

I'm currently working through the "Crafting Interpreters" book by Robert Nystrom. He uses Java to implement the visitor pattern in which the visitor functions return the Object type. C++ ...
GoZaddy's user avatar
  • 33
4 votes
3 answers
192 views

Let's suppose there is a method of an Inputter class that queries many questions. The Human inputter would have to answer all ...
prestokeys's user avatar
  • 1,401
3 votes
1 answer
661 views

Intro I want to visit the value held by a class, which could be of multiple types. This class is very similar to a std::any, so I will be using this in this ...
mfacchinelli's user avatar
3 votes
1 answer
2k views

While solving an online excersise I have written some basic implementation for a visit function that works with std::any. The ...
Sergey Kolesnik's user avatar
0 votes
1 answer
217 views

I have a typescript function that executes an array of actions on a given string value. This is the code: ...
chenny's user avatar
  • 183
3 votes
2 answers
205 views

I'm trying to create a Collider class which will process collisions between different classes of the same base. One restriction is that I want these classes know nothing about each other, now they ...
qloq's user avatar
  • 145
3 votes
0 answers
164 views

In my previous question, one of the answers mentioned that I shouldn't be changing behavior based on the Event class The whole point of classing is that you can get result without having to decide ...
Zymus's user avatar
  • 207
6 votes
0 answers
321 views

I've watched a talk by Fedor Pikus on design patterns held at CppCon 2019. Motivated by this, I wrote my own visitor implementation and some helpers which allow me to create a visitor from a couple of ...
StefanKssmr's user avatar
2 votes
0 answers
113 views

I'm writing my own expression tree system, just for fun, but I have a few doubts about my code. My goal here is to create an abstract layer of expressions, and allow different "languages" to ...
user avatar
5 votes
1 answer
449 views

Inspired by this cppcon talk from Fedor Pikus about design patterns and some real-world need I implemented a library that allows the user to add a generic visitor pattern capabilities to class ...
lucas93's user avatar
  • 51
2 votes
0 answers
92 views

Programming to an interface is a design principle that enhances the flexibility of software by hiding implementation details. Consider an object tree that only exposes an interface, but you want to ...
annemartijn's user avatar
5 votes
1 answer
3k views

I'm required to calculate the average value of all nodes in a BST using a Visitor, I'm not sure if I did this correctly or if i could just calculate the average ...
Phalanx's user avatar
  • 51
4 votes
1 answer
772 views

I'm trying to build an iterator (enumerator) that can select specific elements in an Expression tree by traversing the tree and deferring further iteration until ...
Rhaokiel's user avatar
  • 141
2 votes
3 answers
314 views

Consider the following function to traverse a BST ...
mwal's user avatar
  • 483
7 votes
0 answers
732 views

I have currently two use-cases that require JSON transformations before it can be deserialized. The first use-case requires changing the custom short type property name from ...
t3chb0t's user avatar
  • 44.7k

15 30 50 per page