MCPcopy Create free account
hub / github.com/AllentDan/LibtorchTutorials / value

Function value

lesson6-Segmentation/json.hpp:20279–20295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20277 detail::is_getable<basic_json_t, ValueType>::value
20278 && !std::is_same<value_t, ValueType>::value, int >::type = 0 >
20279 ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const
20280 {
20281 // at only works for objects
20282 if (JSON_HEDLEY_LIKELY(is_object()))
20283 {
20284 // if key is found, return value and given default value otherwise
20285 const auto it = find(key);
20286 if (it != end())
20287 {
20288 return it->template get<ValueType>();
20289 }
20290
20291 return default_value;
20292 }
20293
20294 JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name())));
20295 }
20296
20297 /*!
20298 @brief overload for a default value of type const char*

Callers

nothing calls this directly

Calls 5

is_objectFunction · 0.85
findFunction · 0.85
endFunction · 0.85
createFunction · 0.85
type_nameFunction · 0.85

Tested by

no test coverage detected