Function array_of

Synopsis

#include <include/cpptoml.h>

template <class T>
std::vector< std::shared_ptr< value< T > > > array_of() const

Description

Obtains an array of value<T>s. Note that elements may be nullptr if they cannot be converted to a value<T>.

Source

Lines 843-852 in include/cpptoml.h.

template <class T>
std::vector<std::shared_ptr<value<T>>> array_of() const
{
    std::vector<std::shared_ptr<value<T>>> result(values_.size());
    std::transform(values_.begin(), values_.end(), result.begin(),
                   [&](std::shared_ptr<base> v) { return v->as<T>(); });
    return result;
}





Add Discussion as Guest

Log in