Skip to content

Unable to dump to stringstream #2102

Description

@tjespe
  • What is the issue you have?
    Tried to dump to an ostringstream as specified was possible in the documentation, but cannot compile because the compiler can't find a match for the overloaded operator.

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?

json res = json::object();
std::ostringstream to;
to << res;
  • What is the expected behavior?
    It should compile and dump to stream correctly.

  • And what is the actual behavior instead?
    Compilation error.

error: no match for ‘operator<<’ (operand types are ‘std::ostringstream’ {aka ‘std::__cxx11::basic_ostringstream<char>’} and ‘json’ {aka ‘nlohmann::basic_json<>’})
  136 |     to << res;
      |     ~~ ^~ ~~~
      |     |     |
      |     |     json {aka nlohmann::basic_json<>}
      |     std::ostringstream {aka std::__cxx11::basic_ostringstream<char>}

gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0

  • Did you use a released version of the library or the version from the develop branch?

I am using release v3.7.3 from https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions