MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / value

Function value

external/json/json.hpp:15647–15663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15645 template<class ValueType, typename std::enable_if<
15646 std::is_convertible<basic_json_t, ValueType>::value, int>::type = 0>
15647 ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const
15648 {
15649 // at only works for objects
15650 if (JSON_LIKELY(is_object()))
15651 {
15652 // if key is found, return value and given default value otherwise
15653 const auto it = find(key);
15654 if (it != end())
15655 {
15656 return *it;
15657 }
15658
15659 return default_value;
15660 }
15661
15662 JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name())));
15663 }
15664
15665 /*!
15666 @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