Function get_array_of
Summary
#include <include/cpptoml.h>
(1) template <class T>
array_of_trait< T >::return_type get_array_of() const
(2) template <>
array_of_trait< array >::return_type get_array_of() const
Function overload
Synopsis
#include <include/cpptoml.h>
template <class T>
array_of_trait< T >::return_type get_array_of() const
Description
Obtains a option<vector<T>>. The option will be empty if the array contains values that are not of type T.
Source
Lines 858-873 in include/cpptoml.h.
template <class T>
inline typename array_of_trait<T>::return_type get_array_of() const
{
std::vector<T> result;
result.reserve(values_.size());
for (const auto& val : values_)
{
if (auto v = val->as<T>())
result.push_back(v->get());
else
return {};
}
return {std::move(result)};
}
Synopsis
#include <include/cpptoml.h>
template <>
array_of_trait< array >::return_type get_array_of() const
Description
Obtains a option<vector<T>>. The option will be empty if the array contains values that are not of type T.
Source
Lines 1047-1063 in include/cpptoml.h.
template <>
inline typename array_of_trait<array>::return_type
array::get_array_of<array>() const
{
std::vector<std::shared_ptr<array>> result;
result.reserve(values_.size());
for (const auto& val : values_)
{
if (auto v = val->as_array())
result.push_back(v);
else
return {};
}
return {std::move(result)};
}