From e0e7fa39e755fd1868267eb075c335f7c8a58eee Mon Sep 17 00:00:00 2001 From: Guillaume Racicot Date: Sun, 3 Jun 2018 23:49:13 -0400 Subject: [PATCH 1/2] Re-added external_constructor with string compatible types --- include/nlohmann/detail/conversions/to_json.hpp | 10 ++++++++++ single_include/nlohmann/json.hpp | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index ce2bc0aa..b147d077 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -51,6 +51,16 @@ struct external_constructor j.m_value = std::move(s); j.assert_invariant(); } + + template::value, + int> = 0> + static void construct(BasicJsonType& j, const CompatibleStringType& str) + { + j.m_type = value_t::string; + j.m_value.string = j.template create(str); + j.assert_invariant(); + } }; template<> diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index a886cc9e..630e4027 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -1321,6 +1321,16 @@ struct external_constructor j.m_value = std::move(s); j.assert_invariant(); } + + template::value, + int> = 0> + static void construct(BasicJsonType& j, const CompatibleStringType& str) + { + j.m_type = value_t::string; + j.m_value.string = j.template create(str); + j.assert_invariant(); + } }; template<> From 5676a2a0762ea3a657b2be02d8d9f851f05513a8 Mon Sep 17 00:00:00 2001 From: Guillaume Racicot Date: Sun, 3 Jun 2018 23:51:07 -0400 Subject: [PATCH 2/2] Aligned template declaration --- include/nlohmann/detail/conversions/to_json.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index b147d077..2d4449f4 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -53,8 +53,8 @@ struct external_constructor } template::value, - int> = 0> + enable_if_t::value, + int> = 0> static void construct(BasicJsonType& j, const CompatibleStringType& str) { j.m_type = value_t::string;