From aa2679a8ce1f92b107907cd188762d3c7b0ee9ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20DELRIEU?= Date: Thu, 15 Dec 2016 12:22:53 +0100 Subject: [PATCH] fix tests, avoid instantiating JSONSerializer when it will not be used --- src/json.hpp | 19 ++++++++++--------- test/src/unit-udt.cpp | 14 +++++++------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index e6034029..f883d9ed 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -1614,13 +1614,14 @@ class basic_json template < typename T, enable_if_t>::value and - not detail::is_compatible_basic_json_type< - uncvref_t, basic_json_t>::value and not detail::is_basic_json_nested_class, basic_json_t, primitive_iterator_t>::value and not std::is_same, typename basic_json_t::array_t::iterator>::value and not std::is_same, typename basic_json_t::object_t::iterator>::value and + + detail::conjunction, basic_json_t>>, detail::has_to_json>::value, + uncvref_t>>::value, int> = 0> basic_json(T &&val) { @@ -3311,10 +3312,10 @@ class basic_json template < typename T, - enable_if_t, basic_json_t>::value and + enable_if_t, basic_json_t>>, detail::has_from_json>::value, + uncvref_t>>::value, int> = 0> auto get() const -> uncvref_t { @@ -3331,10 +3332,10 @@ class basic_json // This overload is chosen for non-default constructible user-defined-types template < typename T, - enable_if_t::value and + enable_if_t, basic_json_t>>, detail::has_non_default_from_json::value, + uncvref_t>>::value, short> = 0> T get() const { diff --git a/test/src/unit-udt.cpp b/test/src/unit-udt.cpp index 9ead6eba..364c5ae7 100644 --- a/test/src/unit-udt.cpp +++ b/test/src/unit-udt.cpp @@ -27,6 +27,7 @@ SOFTWARE. */ #include +#include #include #include #include "catch.hpp" @@ -173,19 +174,19 @@ namespace udt template void from_json(Json const& j, age &a) { - a.m_val = j.get(); + a.m_val = j.template get(); } template void from_json(Json const& j, name &n) { - n.m_val = j.get(); + n.m_val = j.template get(); } template void from_json(Json const &j, country &c) { - const auto str = j.get(); + const auto str = j.template get(); static const std::map m = { {u8"中华人民共和国", country::china}, {"France", country::france}, @@ -199,9 +200,9 @@ namespace udt template void from_json(Json const& j, person &p) { - p.m_age = j["age"].get(); - p.m_name = j["name"].get(); - p.m_country = j["country"].get(); + p.m_age = j["age"].template get(); + p.m_name = j["name"].template get(); + p.m_country = j["country"].template get(); } void from_json(nlohmann::json const &j, address &a) @@ -325,7 +326,6 @@ struct adl_serializer TEST_CASE("adl_serializer specialization", "[udt]") { - SECTION("partial specialization") { SECTION("to_json")