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中實現 –