Defined in header <fkYAML/node.hpp>
fkyaml::ordered_map::(constructor)¶
Constructs a new ordered_map.
You can specify the initial value on constructing an ordered_map with an overloaded constructor.
Parameters¶
init
[in]- An initializer list of key-value pairs.
Examples¶
Overload(1): create a default value.
#include <iomanip>
#include <iostream>
#include <fkYAML/node.hpp>
int main() {
fkyaml::ordered_map<std::string, fkyaml::node> om;
std::cout << std::boolalpha << om.empty() << std::endl;
return 0;
}
output:
Overload(2): create an ordered_map object with an initializer list
#include <iostream>
#include <fkYAML/node.hpp>
int main() {
fkyaml::ordered_map<std::string, fkyaml::node> om = {{"foo", 123}, {"bar", "baz"}};
for (auto& pair : om) {
std::cout << pair.first << ": " << pair.second << std::endl;
}
return 0;
}
output: