5
我试图按照this question的逻辑在Rcpp
中创建自定义streambuf
。有人贡献了基本的行为,让我们写的东西像自定义冲洗实施
Rcout << "some text" ;
我们实现xsputn
和overflow
重定向到Rprintf
功能。
std::streamsize Rcpp::Rstreambuf::xsputn(const char *s, std::streamsize num) {
Rprintf("%.*s", num, s);
return num;
}
int Rcpp::Rstreambuf::overflow(int c) {
if (c != EOF) {
Rprintf("%.1s", &c);
}
return c;
}
我想实现冲洗过,即支持这个语法:
Rcout << "some text" << std::flush ;
哪一种方法做我需要实现,使得flush
机械手工作在我的自定义流?
谢谢。在'Rcpp'的svn修订版本3935中实现 –