Function nested_array

Synopsis

#include <include/cpptoml.h>

std::vector< std::shared_ptr< array > > nested_array() const

Description

Obtains an array of arrays. Note that elements may be nullptr if they cannot be converted to a array.

Source

Lines 879-891 in include/cpptoml.h.

std::vector<std::shared_ptr<array>> nested_array() const
{
    std::vector<std::shared_ptr<array>> result(values_.size());
    std::transform(values_.begin(), values_.end(), result.begin(),
                   [&](std::shared_ptr<base> v) -> std::shared_ptr<array> {
                       if (v->is_array())
                           return std::static_pointer_cast<array>(v);
                       return std::shared_ptr<array>{};
                   });
    return result;
}





Add Discussion as Guest

Log in