Skip to content

Conversation

jini-zh
Copy link
Contributor

@jini-zh jini-zh commented Aug 3, 2023

Non-const references cannot be bound to functions results and literals, so the code

Logging log;
try {
  throw std::runtime_error("message");
} catch (std::exception& e) {
  log << e.what() << '\n';
}

ends up calling std::ostream::operator<< both for e.what() and '\n' and produces nothing in the output.

Non-const references cannot be bound to functions results and literals,
so the code
```C++
Logging log;
try {
  throw std::runtime_error("message");
} catch (std::exception& e) {
  log << e.what() << '\n';
}
```
ends up calling `std::ostream::operator<<` both for `e.what()` and
`'\n'` and produces nothing in the output.
@brichards64
Copy link
Contributor

please heck if still relavent

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants