mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
Update How-To-Emit-YAML.md (#976)
This commit is contained in:
@@ -155,15 +155,9 @@ produces
|
|||||||
We overload `operator <<` for `std::vector`, `std::list`, and `std::map`, so you can write stuff like:
|
We overload `operator <<` for `std::vector`, `std::list`, and `std::map`, so you can write stuff like:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
std::vector <int> squares;
|
std::vector <int> squares = {1, 4, 9, 16};
|
||||||
squares.push_back(1);
|
|
||||||
squares.push_back(4);
|
|
||||||
squares.push_back(9);
|
|
||||||
squares.push_back(16);
|
|
||||||
|
|
||||||
std::map <std::string, int> ages;
|
std::map <std::string, int> ages = {{"Daniel", 26}, {"Jesse", 24}};
|
||||||
ages["Daniel"] = 26;
|
|
||||||
ages["Jesse"] = 24;
|
|
||||||
|
|
||||||
YAML::Emitter out;
|
YAML::Emitter out;
|
||||||
out << YAML::BeginSeq;
|
out << YAML::BeginSeq;
|
||||||
@@ -227,4 +221,4 @@ assert(out.good());
|
|||||||
out << YAML::Key;
|
out << YAML::Key;
|
||||||
assert(!out.good());
|
assert(!out.good());
|
||||||
std::cout << "Emitter error: " << out.GetLastError() << "\n";
|
std::cout << "Emitter error: " << out.GetLastError() << "\n";
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user