| 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* |