You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add reference handling to tuples
Signed-off-by: Evelyn LePain <ava.lepain@gmail.com>
* Remove template template type because pair isn't working
Signed-off-by: Evelyn LePain <ava.lepain@gmail.com>
* amalgamate std::tie changes
Signed-off-by: Evelyn LePain <ava.lepain@gmail.com>
* allow the elation of a move by removing the ref requirement
Signed-off-by: Evelyn LePain <ava.lepain@gmail.com>
* force all number_xxx_t to be interchangeable
Signed-off-by: Evelyn LePain <ava.lepain@gmail.com>
* Finally got amalgamate to work correctly
Signed-off-by: Evelyn LePain <ava.lepain@gmail.com>
* remove const version, add a test case for scrambled number representations.
Signed-off-by: Evelyn LePain <ava.lepain@gmail.com>
* Use the logical set of requirements instead of decltype because VS 2015 doesn't like it
Signed-off-by: Evelyn LePain <ava.lepain@gmail.com>
---------
Signed-off-by: Evelyn LePain <ava.lepain@gmail.com>
Copy file name to clipboardExpand all lines: tests/src/unit-constructor1.cpp
+73Lines changed: 73 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -281,6 +281,79 @@ TEST_CASE("constructors")
281
281
// CHECK(std::get<2>(t) == j[2]); // commented out due to CI issue, see https://github.com/nlohmann/json/pull/3985 and https://github.com/nlohmann/json/issues/4025
282
282
}
283
283
284
+
SECTION("std::tuple tie")
285
+
{
286
+
constauto a = 1.0;
287
+
constauto* const b = "string";
288
+
constauto c = 42;
289
+
constauto d = std::vector<int> {0, 2};
290
+
constsize_t e = 1234;
291
+
auto t = std::tie(a, b, c, d, e);
292
+
json constj(t);
293
+
294
+
double a_out = 0;
295
+
std::string b_out;
296
+
int c_out = 0;
297
+
std::vector<int> d_out;
298
+
int64_t e_out = 0;
299
+
auto t_out = std::tie(a_out, b_out, c_out, d_out, e_out);
300
+
j.get_to(t_out);
301
+
CHECK(a_out == a);
302
+
CHECK(b_out == b);
303
+
CHECK(c_out == c);
304
+
CHECK(d_out == d);
305
+
CHECK(e_out == e);
306
+
}
307
+
308
+
SECTION("std::tuple of references to elements")
309
+
{
310
+
constauto a = 1.0;
311
+
constauto* const b = "string";
312
+
constauto c = 42;
313
+
constsize_t d = 1234;
314
+
constauto t = std::tie(a, b, c, d);
315
+
json constj(t);
316
+
317
+
auto t_out = j.get<std::tuple<const json::number_float_t&,
0 commit comments