Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

C++ didn't have variadic templates so passing along a stream with an operator was more ergonomic enough and typesafe.


I suppose you're comparing against std::format, but the question is why overloading an operator (cout << "foo") would have been necessary vs a regular member function (cout.put("foo")).


Because it had to replace people using a comma inside printf. The member function could only accept one argument cleanly so you would've to chain them like cout.put.put.put




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: