Function insert

Summary

#include <include/cpptoml.h>

(1) template <class T>
    iterator insert(iterator position, const std::shared_ptr< value< T >> &value)

(2) iterator insert(iterator position, const std::shared_ptr< array > &value)

(3) template <class T>
    iterator insert(iterator position, T &&val, typename value_traits< T >::type *=0)

Function overload

Synopsis

#include <include/cpptoml.h>

template <class T>
iterator insert(iterator position, const std::shared_ptr< value< T >> &value)

Description

Insert a value into the array

Source

Lines 937-948 in include/cpptoml.h.

template <class T>
iterator insert(iterator position, const std::shared_ptr<value<T>>& value)
{
    if (values_.empty() || values_[0]->as<T>())
    {
        return values_.insert(position, value);
    }
    else
    {
        throw array_exception{"Arrays must be homogenous."};
    }
}

Synopsis

#include <include/cpptoml.h>

iterator insert(iterator position, const std::shared_ptr< array > &value)

Description

Insert an array into the array

Source

Lines 953-963 in include/cpptoml.h.

iterator insert(iterator position, const std::shared_ptr<array>& value)
{
    if (values_.empty() || values_[0]->is_array())
    {
        return values_.insert(position, value);
    }
    else
    {
        throw array_exception{"Arrays must be homogenous."};
    }
}

Synopsis

#include <include/cpptoml.h>

template <class T>
iterator insert(iterator position, T &&val, typename value_traits< T >::type *=0)

Description

Convenience function for inserting a simple element in the array

Source

Lines 968-973 in include/cpptoml.h.

template <class T>
iterator insert(iterator position, T&& val,
                typename value_traits<T>::type* = 0)
{
    return insert(position, make_value(std::forward<T>(val)));
}





Add Discussion as Guest

Log in