相关疑难解决方法(0)

自定义刷新实现

我试图遵循的逻辑这个问题,创建一个自定义streambufRcpp.有人贡献了基本行为,允许我们写出类似的东西

Rcout << "some text" ;
Run Code Online (Sandbox Code Playgroud)

我们在哪里实现xsputnoverflow重定向到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;
}
Run Code Online (Sandbox Code Playgroud)

我也想实现刷新,即支持这种语法:

Rcout << "some text" << std::flush ;
Run Code Online (Sandbox Code Playgroud)

我需要实现哪种方法,以便flush操纵器在我的自定义流上工作?

c++ iostream

5
推荐指数
1
解决办法
553
查看次数

标签 统计

c++ ×1

iostream ×1