C++ std::endl requires <ostream> header

C++ standard library (STL) improvements over time include paring down internal includes where possible as best practice and to improve compilation time. When user code accidentally relies on internal includes, it can lead to compilation errors when the internal includes are removed by the STL maintainers or external libraries. Tools like IWYU can help identify missing or unused include statements.

GCC 15 STL removed some superfluous <ostream> includes that may affect code using std::endl without including <ostream>. It’s a common mistake to assume that <iostream> includes std::endl. When checking code to ensure that std::endl code files include <ostream>, consider if the code could use \n newline instead to improve code performance by avoiding unnecessary stream flushing with std::endl. Part of checking if \n can be used instead of std::endl is to observe if downstream code requires the output buffer to be flushed – for example in interactive CTest runs.