MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/PositionBasedDynamics / value

Method value

extern/json/json.hpp:3699–3719  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3697 template<class ValueType, typename std::enable_if<
3698 std::is_convertible<basic_json_t, ValueType>::value, int>::type = 0>
3699 ValueType value(const typename object_t::key_type& key, ValueType default_value) const
3700 {
3701 // at only works for objects
3702 if (is_object())
3703 {
3704 // if key is found, return value and given default value otherwise
3705 const auto it = find(key);
3706 if (it != end())
3707 {
3708 return *it;
3709 }
3710 else
3711 {
3712 return default_value;
3713 }
3714 }
3715 else
3716 {
3717 throw std::domain_error("cannot use value() with " + type_name());
3718 }
3719 }
3720
3721 /*!
3722 @brief overload for a default value of type const char*

Callers 4

UtilitiesModuleFunction · 0.45
enum_Class · 0.45
valueMethod · 0.45
diffMethod · 0.45

Calls 4

findFunction · 0.85
endFunction · 0.85
get_checkedMethod · 0.80
valueFunction · 0.50

Tested by

no test coverage detected