【问题标题】:YAML ofstream emitter流发射器的 YAML
【发布时间】:2011-09-13 04:18:28
【问题描述】:

我找到了这个例子:

ofstream ofstr("output.yaml");
YAML::Emitter out(ofstr);
out << some_large_document;

// not necessary anymore:
// ofstr << out.c_str()

但是当我尝试使用它时,我有:

D:\work\C\map.cpp||In function `int main()':|
D:\work\C\map.cpp|24|error: no matching function for call to `YAML::Emitter::Emitter(std::ofstream&)'|
D:\work\C\yaml-cpp\emitter.h|23|note: candidates are: YAML::Emitter::Emitter(YAML::Emitter&)|
D:\work\C\yaml-cpp\emitter.h|25|note:                 YAML::Emitter::Emitter()|
||=== Build finished: 1 errors, 0 warnings ===|

【问题讨论】:

    标签: yaml-cpp


    【解决方案1】:

    YAML::Emitter 没有采用流的构造函数。 (你在哪里找到这个例子的?)

    相反,您确实需要使用注释掉的行:

    ofstream ofstr("output.yaml");
    YAML::Emitter out;
    out << some_large_document;
    ofstr << out.c_str(); // is necessary!
    

    【讨论】:

    • @spumer,它在该页面的哪个位置通过传递流构造了YAML::Emitter
    猜你喜欢
    • 1970-01-01
    • 2010-10-19
    • 2018-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多