Skip to content
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

Unable to dump to stringstream #2102

Closed
tjespe opened this issue May 12, 2020 · 1 comment
Closed

Unable to dump to stringstream #2102

tjespe opened this issue May 12, 2020 · 1 comment

Comments

@tjespe
Copy link

tjespe commented May 12, 2020

  • 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

@tjespe
Copy link
Author

tjespe commented May 12, 2020

Turns out I had forgotten to include the sstream header

@tjespe tjespe closed this as completed May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant