Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
78 views

I am creating a QueryBuilder, so I though that it w'd be amazing to serialize objects to tokens, and have an AST within the QueryBuilder. So I immediatly though about the Visitor Design Pattern. Here'...
Alex Vergara's user avatar
  • 2,345
3 votes
1 answer
184 views

I'm trying to implement an inheritable visitor method for a class using CRTP instead of a virtual function. First we have some code like this: #include <iostream> #include <memory> struct ...
Akarin akaza's user avatar
3 votes
2 answers
195 views

I've a C++ concept where I need to check that the class has a particular public attribute. My problem is that the concept works if I use it directly, but fails if I use it in std::visit. This is the ...
Jepessen's user avatar
  • 12.7k
1 vote
1 answer
109 views

I’m designing a C++ API where: Clients only ever use a main trait interface (main_trait). Each concrete main_trait implementation has a dedicated metrics interface (metrics_trait) exposing runtime ...
Andres's user avatar
  • 223
0 votes
2 answers
159 views

I'm trying to use code as below, but I am getting compilation errors. The goal here is to have the "unsupported type in visitor triggered at compile time when a D is passed to visitor. Can ...
user3613174's user avatar
0 votes
3 answers
131 views

I have a lot of polymorphic classes. Each of them has a nested class named Configuration containing all the hyperparameters required by the class. For each class tree, I create a variant of the ...
Caduchon's user avatar
  • 5,278
2 votes
1 answer
89 views

This is the Java example of the visitor pattern in wikipedia: These two interfaces are at the core of the pattern: interface CarElement { void accept(CarElementVisitor visitor); } interface ...
nik's user avatar
  • 411
2 votes
1 answer
66 views

I have a type erased container for holding various classes that meet certain simple requirements. The goal is to provide a consistent interface for similar data-container classes that would then allow ...
Jay Iuliano's user avatar
0 votes
1 answer
65 views

I have various generic containers defined in many different crates using a common declarative macro. Each looks something like: struct Container1<T> { a: T, b: T, } On the other hand, I ...
Josh Burkart's user avatar
0 votes
0 answers
150 views

I'm trying to implement a Open GL (4.6) setup with the Composite pattern (for a scene graph with Node, Cube and TransformNode classes) and the Visitor pattern (with a DrawVisitor to handle rendenring)....
Luis Angel Urena Lopez's user avatar
1 vote
2 answers
135 views

I am trying to build computations against a well defined set of types, much like you would get in a database or dataframe computation library. Given the types are limited but the algorithms are ...
Will Ayd's user avatar
  • 7,204
0 votes
1 answer
155 views

Designing the architecture of a personal project, I've come up with the idea of using the combination of these two patterns to solve an architectural issue. In an MVC context, I need to implement ...
Gareg's user avatar
  • 21
1 vote
2 answers
434 views

I have a question about using a generic visitor with exclusion of non-equal types. Suppose I have the following: using StorageT = std::variant<std::vector<int>, std::vector<double>>; ...
JakeTuero's user avatar
  • 105
0 votes
1 answer
110 views

I'm using a heavily templated library with a function that has multiple template arguments. I'd like to create a dynamic wrapper for this function by creating a class whose members will be the ...
denomme's user avatar
  • 35
3 votes
3 answers
698 views

I am attempting to implement the Visitor design pattern. I have a basic understanding of the Visitor pattern and its classic implementation. I am attempting to morph the visitor pattern to meet my ...
sdub0800's user avatar
  • 181
0 votes
1 answer
67 views

I am working on a lexical and syntax analyser that I amimplementing semantic analysis and intermediate representation generation using ANTLR, and I've encountered a problem with my visitor ...
Cian Sullivan's user avatar
1 vote
1 answer
90 views

I'm trying to use yield in a sequence to lazily emit items from a visitor but I'm getting the error "Suspension functions can be called only within coroutine body". I'm not trying to suspend ...
Alex Lamaison's user avatar
0 votes
0 answers
106 views

I'm working on a serialization library for an embedded target. The library is based on a classic visitor pattern with a templated pack() method implemented in each struct that I want to serialize. ...
klonyyy's user avatar
  • 17
0 votes
1 answer
126 views

I'm preparing a persistent config module for an embedded project. I want to use serialization implemented using the visitor pattern: struct softwareInfo { uint32_t version; std::array<...
klonyyy's user avatar
  • 17
2 votes
1 answer
89 views

I'm trying to build a command pattern where each command has access to a defined interface. Receivers implement one or more of these interfaces and can then have commands, by way of CommandLists ...
Richard Vodden's user avatar
0 votes
1 answer
415 views

I got a "tree" like structure that represents a simple addition expression. (ex 2 + 4 + (3 + 5)) I'm using the visitor pattern to traverse the tree and find the sum. The problem is that I ...
Jacob's user avatar
  • 21
0 votes
1 answer
110 views

Basically I am trying to implement visitors-coding paradigm, where Expr trait needs to be implemented by Binary struct. I want to use Expr as a trait object. Any entity wanting to interact with Expr ...
Adnan's user avatar
  • 98
1 vote
1 answer
1k views

I'm trying to dispatch a variant inside a variant with the visitor overload pattern. However I can't seem to fit the parameters to what is expected. I get this (truncated, for more output see compiler ...
glades's user avatar
  • 5,392
1 vote
2 answers
182 views

I am now using a Visitor pattern where I have 2 visitors using the same interface returning T. It basically looks like the schema below, but my visitor returns something. I would like to change the ...
Lana James's user avatar
-1 votes
1 answer
129 views

I wanted to know why I can't get running any Visitor of generic objects in C#. For some reason the program always picks the least concrete generic overload of my generic. P.S.: I'm not after ...
Alberto's user avatar
  • 605
1 vote
6 answers
1k views

I want to create a mapping from input List<T> to outputList<S>, for the method named foo(List<T>), but in a "smart" way . The way foo(List<T>) processes different ...
Azn Stride's user avatar
1 vote
1 answer
149 views

I'm implementing a visitor pattern and I have some elements that I could implement using generics, but the GNAT compiler complains with the generic type. I have a solution using generic mix-ins but ...
Albatros23's user avatar
1 vote
0 answers
76 views

Given two visitors A and B that sequentially apply transformations to a given AST, is it always possible to automatically merge A and B into a single visitor that, by applying A and B node by node, ...
strblr's user avatar
  • 990
-1 votes
1 answer
146 views

Are there any parts of the standard library that would support the following use case: You have N collections, with each collection potentially being a type of collection (C1, C2 ..., Cn) all of which ...
bpeikes's user avatar
  • 3,739
0 votes
2 answers
144 views

I am studying visiting patterns. However, the following error occurs. not defined. The cat class only has its own name and age. agevisitor and namevisitor, which inherit Visitor interface, output age ...
백승호's user avatar
1 vote
1 answer
614 views

Have a strange case where sometimes a function takes a variant but other times it takes the member of the variant. void branching_function(auto argument) { using typer = std::remove_reference<...
Mikhail's user avatar
  • 8,118
0 votes
0 answers
48 views

Trivially, if I have a base-class and several sub-classes which all implement the same method signature, I can do the following: abstract class BaseClass { public abstract int GetValue(); } class ...
Mr. Boy's user avatar
  • 64.6k
0 votes
2 answers
286 views

I am trying to implement a Visitor pattern in Rust. I am not able to find a way to support two visitors which return different return value types. Playground link trait Visited<R> { fn ...
Gaku Ueda's user avatar
  • 878
5 votes
0 answers
976 views

I have read several articles and answers about the merits of the Acyclic Visitor pattern over the original Visitor pattern. To avoid ambiguity, I refer to the Acyclic Visitor as described in this ...
Aviv's user avatar
  • 51
0 votes
1 answer
142 views

I have a grammar that at some point has the following rule: boolConst : 'true' | 'false'; This leads to the following code (with visitor activated) being generated: class ...
julian's user avatar
  • 73
0 votes
0 answers
94 views

I seem to be losing type info using the visitor design pattern in typescript: abstract class AbsVisitor { public abstract visitPerson(p: Person): void; public abstract visitAddress(p: Address): ...
OrenIshShalom's user avatar
2 votes
2 answers
665 views

This is a follow up on No user defined conversion when using standard variants and visitor pattern I need to implement a templated version of the visitor pattern as shown below, however it looks like ...
Vero's user avatar
  • 351
2 votes
2 answers
525 views

Could you please help me figure out why is this not working i.e. refering to the comment in the code //I need to do this but I can't. I thought this the goal!? I have no idea why this is not working, ...
Vero's user avatar
  • 351
1 vote
1 answer
148 views

Is it possible to print all node ids / values that are traversed in a visit? Take the following code sample: top-down visit(asts) { case x: println(typeOf(x)); } I now get all types of the nodes ...
Teun M.'s user avatar
  • 194
0 votes
2 answers
497 views

I have two datatypes called DragonVector and UnbiasedDragon and I am using visitor pattern for dynamic type inference. I want to extend a DragonVector only by a DragonVector and similarly for ...
shubh gupta's user avatar
0 votes
0 answers
33 views

I am trying to use a visitor 'BehaviorVisitor' which has a method for each type of 'Flower' such as 'Sunflower'. I keep getting this error from BehaviorVisitor: error: variable has incomplete type '...
callum arul's user avatar
0 votes
0 answers
151 views

In a complex C++ program, which is using Xerces, I have to iterate through XML files, and I have to modify its tags. One of the simpliest XML file looks like this: <?xml version="1.0" ...
Business Man's user avatar
-1 votes
1 answer
128 views

When antlr generates java code for visitor pattern, we get a base visitor class. public class YxBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements YxVisitor<T> { /** ...
hnyls2002's user avatar
  • 143
3 votes
0 answers
78 views

Today interviewer told me that Visitor pattern & double dispatch can be used to call non-virtual method of derived class from 3rd party library which source code can't be accessed/changed (this is ...
Soup  Endless's user avatar
0 votes
2 answers
365 views

I have the following use case. I have a restriction interface that needs to fill its members from dependencies, do the validations. These methods are applicable for all implementations and hence it is ...
Gopikrishna K S's user avatar
1 vote
1 answer
300 views

I have the following classes. interface interface1() { void function1() } interface interface2 extends interface1() { void function2() } class implementation1 implements interface1 () { @...
Gopikrishna K S's user avatar
1 vote
0 answers
591 views

I am doing some research on the Visitor Design Pattern implementations in Python and came across an interesting version which I see a lot of potential to use in real world scenarios but it also ...
Ken Masters's user avatar
0 votes
1 answer
180 views

I have been writing a pet programming language using c++. I've mostly settled on using a Visitor Design Pattern to interreact with my AST. The interactions I'll need is some codegen, and various ways ...
Zachary Vander Klippe's user avatar
-1 votes
2 answers
248 views

I want to log each iteration of my text changes nevertheless not sure what should be the proper way of doing that. See below. The first test is GeeksforGeeks and last one will be <i><u><...
Henry's user avatar
  • 935
1 vote
1 answer
490 views

Let the data structure be anything (Array, Vectors, Std::Variant). But what is the difference in traversing using just for/for_each against std::visit. for (auto& Element: collection){ std:...
Rajesh Lakshmipathy's user avatar

1
2 3 4 5
16