Skip to content

Commit 37f1b8b

Browse files
authored
Update How-To-Emit-YAML.md (#976)
1 parent d046eea commit 37f1b8b

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

docs/How-To-Emit-YAML.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,9 @@ produces
155155
We overload `operator <<` for `std::vector`, `std::list`, and `std::map`, so you can write stuff like:
156156

157157
```cpp
158-
std::vector <int> squares;
159-
squares.push_back(1);
160-
squares.push_back(4);
161-
squares.push_back(9);
162-
squares.push_back(16);
158+
std::vector <int> squares = {1, 4, 9, 16};
163159

164-
std::map <std::string, int> ages;
165-
ages["Daniel"] = 26;
166-
ages["Jesse"] = 24;
160+
std::map <std::string, int> ages = {{"Daniel", 26}, {"Jesse", 24}};
167161

168162
YAML::Emitter out;
169163
out << YAML::BeginSeq;
@@ -227,4 +221,4 @@ assert(out.good());
227221
out << YAML::Key;
228222
assert(!out.good());
229223
std::cout << "Emitter error: " << out.GetLastError() << "\n";
230-
```
224+
```

0 commit comments

Comments
 (0)