Search code examples
c++streambuf

Writing custom basic_streambuf


After some time implementing my own streambuf I askes myself if you can use different types for the basic_streambuf like double. Are there any experiences and use cases here?


Solution

  • You're missing the point of streambuf. It's the back end of std::stream. The front end is provided by operator<< and operator>>. Those are overloaded for double. The frond end converts any type to characters, the back end does the I/O (to file, screen, network, whatever)