Skip to content

Defined in header <fkYAML/node.hpp>

fkyaml::ordered_map::(constructor)

ordered_map(); // (1)

ordered_map(std::initializer_list<value_type> init); // (2)

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:

true

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:

foo: 123
bar: baz

See Also