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.

Overload (1)

ordered_map(); // (1)

Constructs an ordered_map object without an initial value.
The content of a newly constructed ordered_map is an empty list of key-value pairs.

Example
#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)

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

Constructs a new ordered_map with an initializer list.
The resulting ordered_map object has the same list of key-value pairs as the given initializer list.

Parameters

init [in]
An initializer list of key-value pairs.
Example
#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