mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add operator<< for basic_streambuf
This commit is contained in:
@@ -651,6 +651,18 @@ basic_streambuf<Allocator>::debug_check() const
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class Alloc, class T>
|
||||
basic_streambuf<Alloc>&
|
||||
operator<< (basic_streambuf<Alloc>& buf, T const& t)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << t;
|
||||
auto const& s = ss.str();
|
||||
buf.commit(boost::asio::buffer_copy(
|
||||
buf.prepare(s.size()), boost::asio::buffer(s)));
|
||||
return buf;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using streambuf = basic_streambuf<std::allocator<char>>;
|
||||
|
||||
Reference in New Issue
Block a user