Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polymorphism not used for PrettyWriter #2278

Open
mondus opened this issue May 15, 2024 · 1 comment · May be fixed by #2279
Open

Polymorphism not used for PrettyWriter #2278

mondus opened this issue May 15, 2024 · 1 comment · May be fixed by #2279

Comments

@mondus
Copy link

mondus commented May 15, 2024

PrettyWritter extends the Writer class but the base class methods are not virtual and as such if a pointer to a PrettyWriter is cast to a Writer the default behaviour is that output is not written using pretty formatting.

See: FLAMEGPU/FLAMEGPU2#1205

@mondus mondus linked a pull request May 15, 2024 that will close this issue
2 tasks
@nglass
Copy link

nglass commented May 24, 2024

I disagree with this approach. Rapidjson is fast because it uses CRTP aka static-polymorphism. Introducing virtual on all the handler callbacks will cause a significant overhead for other users of the library.
IMO you should introduce a writer template to your JSONStateWriter so you can have two implementations. one for writer and one for prettywriter.

It looks like you already do use templates for your JSONGraphWriter

template<typename T> void writeAnyVertex(T &writer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants