@@ -3229,7 +3229,7 @@ class basic_json
32293229#endif
32303230 && detail::is_detected<detail::get_template_function, const basic_json_t &, ValueType>::value
32313231 , int >::type = 0 >
3232- operator ValueType () const
3232+ JSON_EXPLICIT operator ValueType () const
32333233 {
32343234 // delegate the call to get<>() const
32353235 return get<ValueType>();
@@ -3784,8 +3784,9 @@ class basic_json
37843784
37853785 @since version 1.0.0
37863786 */
3787+ // using std::is_convertible in a std::enable_if will fail when using explicit conversions
37873788 template < class ValueType , typename std::enable_if <
3788- std::is_convertible <basic_json_t , ValueType>::value
3789+ detail::is_getable <basic_json_t , ValueType>::value
37893790 && !std::is_same<value_t , ValueType>::value, int >::type = 0 >
37903791 ValueType value (const typename object_t ::key_type& key, const ValueType& default_value) const
37913792 {
@@ -3796,7 +3797,7 @@ class basic_json
37963797 const auto it = find (key);
37973798 if (it != end ())
37983799 {
3799- return *it ;
3800+ return it-> template get <ValueType>() ;
38003801 }
38013802
38023803 return default_value;
@@ -3858,7 +3859,7 @@ class basic_json
38583859 @since version 2.0.2
38593860 */
38603861 template <class ValueType , typename std::enable_if<
3861- std::is_convertible <basic_json_t , ValueType>::value, int >::type = 0 >
3862+ detail::is_getable <basic_json_t , ValueType>::value, int >::type = 0 >
38623863 ValueType value (const json_pointer& ptr, const ValueType& default_value) const
38633864 {
38643865 // at only works for objects
@@ -3867,7 +3868,7 @@ class basic_json
38673868 // if pointer resolves a value, return it or use default value
38683869 JSON_TRY
38693870 {
3870- return ptr.get_checked (this );
3871+ return ptr.get_checked (this ). template get <ValueType>() ;
38713872 }
38723873 JSON_INTERNAL_CATCH (out_of_range&)
38733874 {
@@ -8341,8 +8342,8 @@ class basic_json
83418342 }
83428343
83438344 // collect mandatory members
8344- const std::string op = get_value (" op" , " op" , true );
8345- const std::string path = get_value (op, " path" , true );
8345+ const auto op = get_value (" op" , " op" , true ). template get <std::string>( );
8346+ const auto path = get_value (op, " path" , true ). template get <std::string>( );
83468347 json_pointer ptr (path);
83478348
83488349 switch (get_op (op))
@@ -8368,7 +8369,7 @@ class basic_json
83688369
83698370 case patch_operations::move:
83708371 {
8371- const std::string from_path = get_value (" move" , " from" , true );
8372+ const auto from_path = get_value (" move" , " from" , true ). template get <std::string>( );
83728373 json_pointer from_ptr (from_path);
83738374
83748375 // the "from" location must exist - use at()
@@ -8385,7 +8386,7 @@ class basic_json
83858386
83868387 case patch_operations::copy:
83878388 {
8388- const std::string from_path = get_value (" copy" , " from" , true );
8389+ const auto from_path = get_value (" copy" , " from" , true ). template get <std::string>( );
83898390 const json_pointer from_ptr (from_path);
83908391
83918392 // the "from" location must exist - use at()
0 commit comments