Replies: 1 comment 2 replies
-
@GJanos |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Dear @stephenberry !
I made a post about this earlier, but this deserves its separate discussion.
I completed a small demo code that explains one of my problems. When I run this, instead of incrementing numbers getting printed, I only get 10 10 times.
Log output: 10 pieces of 10. No incrementing numbers, because of the glz::obj taking the cnt value as a const int&.
This problem could be handles with casting the cnt value as type, so it does not taken by reference. But I think that is not the most elegant way to solve this issue.
Glz::obj taking references indeed improve performance, but sometimes occasional deep-copies are needed. Especially when a glz::obj would want to be logged, so it would get copied and the copy would be put to a backend threads spnc queue for later work. But because of a shallow-copy getting made, the values of the object inside of the queue would get corrupted.
For this reason it would be an awesome feature to be able to customize the glz::obj and maybe even your own types (but currently glz::obj is the priority) whether you want them shallow or deep-copied.
Glaze already supports something like:
This would make the systax a lot nicer.
Basically I would need a way to deep copy glz::obj on the stack. Not with moving the data or references.
Thank you for your time!
Beta Was this translation helpful? Give feedback.
All reactions