| 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* |
no test coverage detected