Daily bit(e) of C++ | std::spanstream
Daily bit(e) of C++ ♻️78, The C++23 alternative to std::stringstream, the std::span-based std::spanstream.
The std::spanstream is a C++23 alternative to std::stringstream that operates on top of a std::span instead of a std::string, eliminating the need for dynamic allocation.
A std::spanstream can directly parse text stored in raw memory, string_views or string literals (any contiguous range).
When used for output, the std::spanstream will allow as much output as fits into the wrapped range, potentially truncating the output in the process.