From ec4e45219af1d7cde3d58b49ed762376fccf1ace Mon Sep 17 00:00:00 2001 From: j4cbo Date: Tue, 20 Jun 2017 16:48:22 -0700 Subject: [PATCH] Change Json map/vector conversions to invoke begin() directly (#110) ... instead of using key_type/value_type/mapped_type. Because this could otherwise false-positive on things like std::optional, which has a value_type member type, but is not a container. Fixes #109. --- json11.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/json11.hpp b/json11.hpp index 5202ef9..0c47d05 100644 --- a/json11.hpp +++ b/json11.hpp @@ -107,14 +107,14 @@ class Json final { // Implicit constructor: map-like objects (std::map, std::unordered_map, etc) template ::value - && std::is_constructible::value, + std::is_constructible().begin()->first)>::value + && std::is_constructible().begin()->second)>::value, int>::type = 0> Json(const M & m) : Json(object(m.begin(), m.end())) {} // Implicit constructor: vector-like objects (std::list, std::vector, std::set, etc) template ::value, + std::is_constructible().begin())>::value, int>::type = 0> Json(const V & v) : Json(array(v.begin(), v.end())) {}