 <p>Build a string up, and then print it out:</p> <pre><code>std::stringstream value; for (int i=0;i&lt;N;i++) { value &lt;&lt; covariance[0][i]; if (i + 1 &lt; N) { value &lt;&lt; ","; } } YAML::Emitter out; out &lt;&lt; YAML::BeginMap; out &lt;&lt; YAML::Key &lt;&lt; "covariance" &lt;&lt; YAML::Value &lt;&lt; value.str(); out &lt;&lt; YAML::EndMap; </code></pre> <p>The point is that the value you're printing isn't a YAML list, it's just a plain string that happens to look a little bit like YAML. So you can't use yaml-cpp to format it for you; you need to do that yourself.</p>