我想通过一些例子学习boost :: iostreams。这里是其中的一个不能用GCC接受:boost :: iostreams编译错误::复制
#include <iostream>
#include <boost/iostreams/filter/regex.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/device/back_inserter.hpp>
using namespace std;
int main()
{
boost::regex reg("a.c");
string str("abcdef aochijk");
string result;
boost::iostreams::copy(
boost::make_iterator_range(str),
boost::iostreams::filtering_ostream(
boost::iostreams::regex_filter(reg,"test") |
boost::iostreams::back_inserter(result))
);
cout<<result<<endl;
return 0;
}
这里是错误:
error:no matching function for call to 'copy(boost::iterator_range<__gnu_cxx::__normal_iterator<char*, std::basic_string<char> > >, boost::iostreams::filtering_ostream)'
error:no type named 'type' in 'struct boost::disable_if<boost::iostreams::is_std_io<boost::iostreams::filtering_stream<boost::iostreams::output> >, void>'
你从哪儿弄来这个例子的代码? – 2013-03-24 13:14:13
@JohnZwinck从本书介绍提升。我无法编译任何包含boost :: iostreams :: copy的代码。 – user957121 2013-03-24 14:06:46