-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Can we have a json_view class like std::string_view? #1158
Comments
Could you provide more information or examples? |
The use case is that, there is an immutable template nlohmann::json object as below, and there would have thousands of concurrent access to it.
Each access will
I want to avoid the the copy in the first step. (The concept is not same as std::string_view class, but the non-owning concept would be similar) |
I think I understand the issue, but I am skeptical whether an implementation to this library is possible (or at least: possible without too much effort). |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
One premature thinking is to have a json_view class which accepts const JSON references parameters to construct new JSONs. In this case, we avoid data copying, but leave the referred objects' lifetime management to the user, and It will cause undefined behavior if use incorrectly. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
As copy a json would have many allocations, it would nice to have a view class like std::string_view for performance's sake.
The text was updated successfully, but these errors were encountered: