Skip to content

Commit 12b707c

Browse files
geissonatorkraj
authored andcommitted
nlohmann-json: backport gcc10 fix
The following issue and PR describe an issue with nlohmann-json and GCC10. nlohmann/json#1920 nlohmann/json#2034 Confirmed that this fixed the issue seen in OpenBMC when pulling in the latest upstream meta-openembedded. Signed-off-by: Khem Raj <[email protected]>
1 parent 5c6f679 commit 12b707c

File tree

3 files changed

+146
-1
lines changed

3 files changed

+146
-1
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
From ec955f08b47ab7cb81f6e4a4c3e7b331ddf50f71 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Art=C3=B6m=20Bakri=20Al-Sarmini?= <[email protected]>
3+
Date: Sun, 12 Apr 2020 22:32:39 +0300
4+
Subject: [PATCH] Templatize basic_json ctor from json_ref
5+
6+
Upstream-Status: Backport [https://github.com/nlohmann/json/commit/ec955f08b47ab7cb81f6e4a4c3e7b331ddf50f71]
7+
Signed-off-by: Andrew Geissler <[email protected]>
8+
9+
---
10+
include/nlohmann/detail/meta/type_traits.hpp | 13 ++++++++++++
11+
include/nlohmann/json.hpp | 8 ++++----
12+
single_include/nlohmann/json.hpp | 21 ++++++++++++++++----
13+
3 files changed, 34 insertions(+), 8 deletions(-)
14+
15+
diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp
16+
index 280f6953..dd0b3084 100644
17+
--- a/include/nlohmann/detail/meta/type_traits.hpp
18+
+++ b/include/nlohmann/detail/meta/type_traits.hpp
19+
@@ -41,6 +41,19 @@ template<typename> struct is_basic_json : std::false_type {};
20+
NLOHMANN_BASIC_JSON_TPL_DECLARATION
21+
struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {};
22+
23+
+//////////////////////
24+
+// jspn_ref helpers //
25+
+//////////////////////
26+
+
27+
+template <typename>
28+
+class json_ref;
29+
+
30+
+template<typename>
31+
+struct is_json_ref : std::false_type {};
32+
+
33+
+template <typename T>
34+
+struct is_json_ref<json_ref<T>> : std::true_type {};
35+
+
36+
//////////////////////////
37+
// aliases for detected //
38+
//////////////////////////
39+
diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp
40+
index 336d69fe..0598efc8 100644
41+
--- a/include/nlohmann/json.hpp
42+
+++ b/include/nlohmann/json.hpp
43+
@@ -1773,10 +1773,10 @@ class basic_json
44+
// other constructors and destructor //
45+
///////////////////////////////////////
46+
47+
- /// @private
48+
- basic_json(const detail::json_ref<basic_json>& ref)
49+
- : basic_json(ref.moved_or_copied())
50+
- {}
51+
+ template <typename JsonRef,
52+
+ detail::enable_if_t<detail::conjunction<detail::is_json_ref<JsonRef>,
53+
+ std::is_same<typename JsonRef::value_type, basic_json>>::value, int> = 0 >
54+
+ basic_json(const JsonRef& ref) : basic_json(ref.moved_or_copied()) {}
55+
56+
/*!
57+
@brief copy constructor
58+
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp
59+
index 09464f3b..8927180e 100644
60+
--- a/single_include/nlohmann/json.hpp
61+
+++ b/single_include/nlohmann/json.hpp
62+
@@ -2794,6 +2794,19 @@ template<typename> struct is_basic_json : std::false_type {};
63+
NLOHMANN_BASIC_JSON_TPL_DECLARATION
64+
struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {};
65+
66+
+//////////////////////
67+
+// jspn_ref helpers //
68+
+//////////////////////
69+
+
70+
+template <typename>
71+
+class json_ref;
72+
+
73+
+template<typename>
74+
+struct is_json_ref : std::false_type {};
75+
+
76+
+template <typename T>
77+
+struct is_json_ref<json_ref<T>> : std::true_type {};
78+
+
79+
//////////////////////////
80+
// aliases for detected //
81+
//////////////////////////
82+
@@ -16632,10 +16645,10 @@ class basic_json
83+
// other constructors and destructor //
84+
///////////////////////////////////////
85+
86+
- /// @private
87+
- basic_json(const detail::json_ref<basic_json>& ref)
88+
- : basic_json(ref.moved_or_copied())
89+
- {}
90+
+ template <typename JsonRef,
91+
+ detail::enable_if_t<detail::conjunction<detail::is_json_ref<JsonRef>,
92+
+ std::is_same<typename JsonRef::value_type, basic_json>>::value, int> = 0 >
93+
+ basic_json(const JsonRef& ref) : basic_json(ref.moved_or_copied()) {}
94+
95+
/*!
96+
@brief copy constructor
97+
--
98+
2.21.0 (Apple Git-122)
99+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
From 70be9751cd60e622ce6463f41d47c02fc2d83cbc Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Art=C3=B6m=20Bakri=20Al-Sarmini?= <[email protected]>
3+
Date: Sun, 12 Apr 2020 23:42:26 +0300
4+
Subject: [PATCH] typo fix
5+
6+
Upstream-Status: Backport [https://github.com/nlohmann/json/commit/70be9751cd60e622ce6463f41d47c02fc2d83cbc]
7+
8+
Signed-off-by: Andrew Geissler <[email protected]>
9+
10+
---
11+
include/nlohmann/detail/meta/type_traits.hpp | 2 +-
12+
single_include/nlohmann/json.hpp | 2 +-
13+
2 files changed, 2 insertions(+), 2 deletions(-)
14+
15+
diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp
16+
index dd0b3084..13e92cb4 100644
17+
--- a/include/nlohmann/detail/meta/type_traits.hpp
18+
+++ b/include/nlohmann/detail/meta/type_traits.hpp
19+
@@ -42,7 +42,7 @@ NLOHMANN_BASIC_JSON_TPL_DECLARATION
20+
struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {};
21+
22+
//////////////////////
23+
-// jspn_ref helpers //
24+
+// json_ref helpers //
25+
//////////////////////
26+
27+
template <typename>
28+
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp
29+
index 8927180e..294e7509 100644
30+
--- a/single_include/nlohmann/json.hpp
31+
+++ b/single_include/nlohmann/json.hpp
32+
@@ -2795,7 +2795,7 @@ NLOHMANN_BASIC_JSON_TPL_DECLARATION
33+
struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {};
34+
35+
//////////////////////
36+
-// jspn_ref helpers //
37+
+// json_ref helpers //
38+
//////////////////////
39+
40+
template <typename>
41+
--
42+
2.21.0 (Apple Git-122)
43+

meta-oe/recipes-devtools/nlohmann-json/nlohmann-json_3.7.3.bb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ SECTION = "libs"
44
LICENSE = "MIT"
55
LIC_FILES_CHKSUM = "file://LICENSE.MIT;md5=f5f7c71504da070bcf4f090205ce1080"
66

7-
SRC_URI = "git://github.com/nlohmann/json.git;nobranch=1"
7+
SRC_URI = "git://github.com/nlohmann/json.git;nobranch=1 \
8+
file://0001-Templatize-basic_json-ctor-from-json_ref.patch \
9+
file://0001-typo-fix.patch \
10+
"
811

912
SRCREV = "e7b3b40b5a95bc74b9a7f662830a27c49ffc01b4"
1013

0 commit comments

Comments
 (0)