Skip to main content
4 events
when toggle format what by license comment
May 3, 2021 at 21:53 comment added LB2 This is buys ability to construct and take advantage of overloaded << that stringify complex structures without requiring being able to declare local variable in context where such variable cannot be declared. E.g. in constructor initialization lists so that you can construct class with a constant string field. That you cannot do if your syntax requires local variables (or doing even crazier theatrics like C-style function calls or lambdas. @Lightness_races_in_orbit's answer is perfect for such cases.
Apr 4, 2014 at 14:15 comment added Loki Astari @uckelman: Yes. That is NOT what I am debating. If you see my code that part has not changed. My argument is that adding an extra list to make an explicit object (rather than a temporary) is more readable and only adds a single line.
Apr 4, 2014 at 9:01 comment added uckelman The advantage is atomicity. Single calls to operator<< on std::cout and std::cerr are guaranteed to be atomic. You can get interleaving with output from other threads with std::cout << 'a' << 1 << false;, but not with std::cout << static_cast<const stringstream&>(std::stringstream() << 'a' << 1 << false).str();.
Nov 16, 2011 at 11:55 history answered Loki Astari CC BY-SA 3.0