# toml++ — Arrays ## Overview `toml::array` extends `toml::node` and models a heterogeneous, ordered sequence of TOML nodes. Unlike C++ standard containers that store elements of a single type, a TOML array can contain any mix of value types, sub-tables, and nested arrays. Declared in `include/toml++/impl/array.hpp` with implementation in `array.inl`. --- ## Internal Storage ```cpp class array : public node { private: std::vector elems_; // impl::node_ptr = std::unique_ptr }; ``` - Each element is owned via `std::unique_ptr` - The array owns all child nodes — destruction cascades - Elements can be any `node` subclass: `value`, `table`, or nested `array` --- ## Construction ### Default Construction ```cpp toml::array arr; // empty array ``` ### Initializer List Construction ```cpp auto arr = toml::array{ 1, 2, 3 }; // array of integers auto mixed = toml::array{ 1, "hello", 3.14, true }; // mixed types auto nested = toml::array{ toml::array{ 1, 2 }, toml::array{ 3, 4 } }; // Array of tables (array-of-tables syntax in TOML) auto aot = toml::array{ toml::table{ { "name", "Alice" }, { "age", 30 } }, toml::table{ { "name", "Bob" }, { "age", 25 } } }; ``` Values are converted to nodes via `impl::make_node()`: - `int`, `int64_t` → `value` - `double`, `float` → `value` - `const char*`, `std::string` → `value` - `bool` → `value` - `toml::date` → `value` - `toml::time` → `value