-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
json_pointer - a code example from doc's does not compile #4453
Comments
I'm having a similar issue using json_pointers which we use extensively on openFrameworks projectGenerator
errors like this in code that used to work well before 3.11.3 |
The compilation errors occur because the constructor of So, I think the better approach is to adjust the example code to use direct initialization. Minimal code example (Modified)#include <string>
#include "json.hpp"
using json = nlohmann::json;
int main()
{
std::string ptrStr = "/nested";
ptrStr += "/one";
json::json_pointer ptr1("/nested/one");
auto ptr2 = "/nested/one"_json_pointer;
json::json_pointer ptr3(ptrStr);
} |
This issue has been marked as stale because it has been open for 90 days without activity. If this issue is still relevant, please add a comment or remove the "stale" label. Otherwise, it will be closed in 10 days. Thank you for helping us prioritize our work! |
I can confirm the issue. |
Description
Gnu C++ does not compile the code example below. GCC 11.4.0, with -std=c++11 option
Example taken from https://json.nlohmann.me/features/json_pointer/#introduction
json::json_pointer p = "/nested/one";
main.cpp code found in "Minimal code example" field.
The _json_pointer literal is the only line that compiles correctly.
note: Clang compiler (clang++ v14.0.0) basically reports the same errors.
Reproduction steps
g++ main.cpp --std=c++11
Expected vs. actual results
JSON Pointer creation¶
JSON Pointers can be created from a string:
json::json_pointer p = "/nested/one";
Minimal code example
Error messages
Compiler and operating system
Ubuntu 22.04
Library version
3.11.1 and 3.11.3
Validation
develop
branch is used.The text was updated successfully, but these errors were encountered: