How to pipe into std::cout with boost::iostreams
问题 I am new to boost::iostreams so this might be trivial: Assuming namespace io = boost::iostreams; this works io::filtering_ostream out(std::cout); out << "some\nstring\n"; and this works std::string result; io::filtering_ostream out(io::counter() | io::back_inserter(result)); out << "some\nstring\n"; yet this does not compile io::filtering_ostream out(io::counter() | std::cout); out << "some\nstring\n"; How do you pipe into std::cout ? 回答1: Wrapping std::cout with boost::ref worked for me: io: