Function get_impl
Summary
#include <include/cpptoml.h>
(1) template <class T>
std::enable_if<!std::is_floating_point< T >::value &&std::is_signed< T >::value, option< T > >::type get_impl(const std::shared_ptr< base > &elem)
(2) template <class T>
std::enable_if<!std::is_same< T, bool >::value &&std::is_unsigned< T >::value, option< T > >::type get_impl(const std::shared_ptr< base > &elem)
(3) template <class T>
std::enable_if<!std::is_integral< T >::value||std::is_same< T, bool >::value, option< T > >::type get_impl(const std::shared_ptr< base > &elem)
Function overload
Synopsis
#include <include/cpptoml.h>
template <class T>
std::enable_if<!std::is_floating_point< T >::value &&std::is_signed< T >::value, option< T > >::type get_impl(const std::shared_ptr< base > &elem)
Description
No description yet.
Source
Lines 1218-1240 in include/cpptoml.h.
template <class T>
typename std::enable_if<!std::is_floating_point<T>::value
&& std::is_signed<T>::value,
option<T>>::type
get_impl(const std::shared_ptr<base>& elem)
{
if (auto v = elem->as<int64_t>())
{
if (v->get() < (std::numeric_limits<T>::min)())
throw std::underflow_error{
"T cannot represent the value requested in get"};
if (v->get() > (std::numeric_limits<T>::max)())
throw std::overflow_error{
"T cannot represent the value requested in get"};
return {static_cast<T>(v->get())};
}
else
{
return {};
}
}
Synopsis
#include <include/cpptoml.h>
template <class T>
std::enable_if<!std::is_same< T, bool >::value &&std::is_unsigned< T >::value, option< T > >::type get_impl(const std::shared_ptr< base > &elem)
Description
No description yet.
Source
Lines 1242-1263 in include/cpptoml.h.
template <class T>
typename std::enable_if<!std::is_same<T, bool>::value
&& std::is_unsigned<T>::value,
option<T>>::type
get_impl(const std::shared_ptr<base>& elem)
{
if (auto v = elem->as<int64_t>())
{
if (v->get() < 0)
throw std::underflow_error{"T cannot store negative value in get"};
if (static_cast<uint64_t>(v->get()) > (std::numeric_limits<T>::max)())
throw std::overflow_error{
"T cannot represent the value requested in get"};
return {static_cast<T>(v->get())};
}
else
{
return {};
}
}
Synopsis
#include <include/cpptoml.h>
template <class T>
std::enable_if<!std::is_integral< T >::value||std::is_same< T, bool >::value, option< T > >::type get_impl(const std::shared_ptr< base > &elem)
Description
No description yet.
Source
Lines 1265-1279 in include/cpptoml.h.
template <class T>
typename std::enable_if<!std::is_integral<T>::value
|| std::is_same<T, bool>::value,
option<T>>::type
get_impl(const std::shared_ptr<base>& elem)
{
if (auto v = elem->as<T>())
{
return {v->get()};
}
else
{
return {};
}
}