ostreams 库提供了一个从STL容器读取的简单方法:boost::iterator_range 实例可以直接附加到 filtering streams and stream buffers带过滤的流和流缓冲 上
namespace io = boost::iostreams;
int main(){
using namespace std;
typedef my_source<string> string_source;
string input = "Hello World";
string output;
io::stream<string_source> in(input);
getline(in,output);
assert(input == output);
}
Iostreams 库提供了一个从STL容器读取的简单方法。首先,输出迭代器可以直接附加到 filtering streams and stream buffers带过滤的流和流缓冲 上
namespace io = boost::iostreams;
int main()
{
using namespace std;
string result;
io::filtering_ostream out(io::back_inserter(result));
out << "Hello World!";
out.flush();
assert(result == "Hello World!");
}