Lines 1-63
Link Here
|
1 |
https://github.com/nlohmann/json/commit/8165707990e4 |
|
|
2 |
|
3 |
--- 3rd-party/json.hpp.orig 2018-06-24 19:26:15 UTC |
4 |
+++ 3rd-party/json.hpp |
5 |
@@ -353,6 +353,16 @@ struct is_compatible_object_type_impl<true, RealType, |
6 |
std::is_constructible<typename RealType::mapped_type, typename CompatibleObjectType::mapped_type>::value; |
7 |
}; |
8 |
|
9 |
+template<bool B, class RealType, class CompatibleStringType> |
10 |
+struct is_compatible_string_type_impl : std::false_type {}; |
11 |
+ |
12 |
+template<class RealType, class CompatibleStringType> |
13 |
+struct is_compatible_string_type_impl<true, RealType, CompatibleStringType> |
14 |
+{ |
15 |
+ static constexpr auto value = |
16 |
+ std::is_same<typename RealType::value_type, typename CompatibleStringType::value_type>::value; |
17 |
+}; |
18 |
+ |
19 |
template<class BasicJsonType, class CompatibleObjectType> |
20 |
struct is_compatible_object_type |
21 |
{ |
22 |
@@ -363,6 +373,15 @@ struct is_compatible_object_type |
23 |
typename BasicJsonType::object_t, CompatibleObjectType >::value; |
24 |
}; |
25 |
|
26 |
+template<class BasicJsonType, class CompatibleStringType> |
27 |
+struct is_compatible_string_type |
28 |
+{ |
29 |
+ static auto constexpr value = is_compatible_string_type_impl < |
30 |
+ conjunction<negation<std::is_same<void, CompatibleStringType>>, |
31 |
+ has_value_type<CompatibleStringType>>::value, |
32 |
+ typename BasicJsonType::string_t, CompatibleStringType >::value; |
33 |
+}; |
34 |
+ |
35 |
template<typename BasicJsonType, typename T> |
36 |
struct is_basic_json_nested_type |
37 |
{ |
38 |
@@ -974,6 +993,25 @@ void from_json(const BasicJsonType& j, typename BasicJ |
39 |
{ |
40 |
JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); |
41 |
} |
42 |
+ s = *j.template get_ptr<const typename BasicJsonType::string_t*>(); |
43 |
+} |
44 |
+ |
45 |
+template < |
46 |
+ typename BasicJsonType, typename CompatibleStringType, |
47 |
+ enable_if_t < |
48 |
+ is_compatible_string_type<BasicJsonType, CompatibleStringType>::value and |
49 |
+ not std::is_same<typename BasicJsonType::string_t, |
50 |
+ CompatibleStringType>::value and |
51 |
+ std::is_constructible < |
52 |
+ BasicJsonType, typename CompatibleStringType::value_type >::value, |
53 |
+ int > = 0 > |
54 |
+void from_json(const BasicJsonType& j, CompatibleStringType& s) |
55 |
+{ |
56 |
+ if (JSON_UNLIKELY(not j.is_string())) |
57 |
+ { |
58 |
+ JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); |
59 |
+ } |
60 |
+ |
61 |
s = *j.template get_ptr<const typename BasicJsonType::string_t*>(); |
62 |
} |
63 |
|