MCPcopy Create free account
hub / github.com/dhbloo/rapfi / get_impl

Function get_impl

Rapfi/external/cpptoml/include/cpptoml.h:1220–1241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1218
1219template <class T>
1220typename std::enable_if<!std::is_floating_point<T>::value
1221 && std::is_signed<T>::value,
1222 option<T>>::type
1223get_impl(const std::shared_ptr<base>& elem)
1224{
1225 if (auto v = elem->as<int64_t>())
1226 {
1227 if (v->get() < (std::numeric_limits<T>::min)())
1228 throw std::underflow_error{
1229 "T cannot represent the value requested in get"};
1230
1231 if (v->get() > (std::numeric_limits<T>::max)())
1232 throw std::overflow_error{
1233 "T cannot represent the value requested in get"};
1234
1235 return {static_cast<T>(v->get())};
1236 }
1237 else
1238 {
1239 return {};
1240 }
1241}
1242
1243template <class T>
1244typename std::enable_if<!std::is_same<T, bool>::value

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected