Remix.run Logo
einpoklum 4 days ago

> operator<<() ... widely used in the standard library

Not that widely. You must be thinking of the IO streams part of the library. Yes, it's rather poor in many respects. But you don't have to use it! We have perfectly nice variadic printing functions these days!

    auto number = 42;
    std::println("Hello, {}! The answer is {}", "world", number);
loeg 3 days ago | parent [-]

std::println dates to C++23. This is very recent. You only have to be using Clang 18 (March 2024) or older to find the feature unsupported: https://godbolt.org/z/xPqYafhss (Clang 19 dates to September 2024, only a year ago.)

In contrast, the standard C++ stream types have used operator<< overloading for more than 25 years. glog/gtest assertions continue to use it.

einpoklum 3 days ago | parent [-]

I said "these days"... C++ is an evolving language. And while it doesn't throw things away, it does collect enough "stuff" that you can choose to write nicer and more straightforward code than before.