Skip to content

json_pointer__pop_back.cpp example does not compile #3600

@nlohmann

Description

@nlohmann

Description

Example https://github.com/nlohmann/json/blob/develop/docs/examples/json_pointer__pop_back.cpp does not compile.

It used to compile. Not sure when this broke.

Reproduction steps

Call

make -C docs

Expected vs. actual results

Expected: code compiles

Actual:

GCC:

examples/json_pointer__back.cpp: In function 'int main()':
examples/json_pointer__back.cpp:13:45: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and 'nlohmann::basic_json<>::json_pointer' {aka 'nlohmann::json_pointer<std::__cxx11::basic_string<char> >'})
   13 |     std::cout << "last reference token of " << ptr1 << " is " << ptr1.back() << '\n'
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~ ~~~~
      |               |                                |
      |               std::basic_ostream<char>         nlohmann::basic_json<>::json_pointer {aka nlohmann::json_pointer<std::__cxx11::basic_string<char> >}

Clang:

examples/json_pointer__back.cpp:13:45: error: invalid operands to binary expression ('basic_ostream<char, std::char_traits<char>>' and 'json::json_pointer' (aka 'json_pointer<std::string>'))
    std::cout << "last reference token of " << ptr1 << " is " << ptr1.back() << '\n'
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~

Minimal code example

No response

Error messages

No response

Compiler and operating system

Apple clang version 13.1.6 (clang-1316.0.21.2.5) and g++-11 (Homebrew GCC 11.3.0_2) 11.3.0

Library version

develop

Validation

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions