From 21cdb11346ac01313dcdde4beeaf9bceb8f97b67 Mon Sep 17 00:00:00 2001 From: Richard Hodges Date: Tue, 17 Nov 2020 07:08:03 +0100 Subject: [PATCH] Fix value_to and value_from for MSVC-14.0: close #465 value_to and value_from was incorrectly deducing that std::string was "array-like" rather than "string-like", but only on msvc-14.0 Original test: template, const char*, std::size_t>::value && std::is_convertible().data()), const char*>::value && std::is_convertible().size()), std::size_t>::value >::type* = nullptr> Which works for all compilers except msvc-14.0 New test: template, const char*, std::size_t>::value && std::is_convertible().data()), const char*>::value && std::is_integral().size())>::value >::type* = nullptr> Note that each individual test works on all compilers. It seems to be the conjuction of tests that caused msvc-14 to trip up. --- include/boost/json/detail/value_from.hpp | 8 +++++--- include/boost/json/detail/value_to.hpp | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/boost/json/detail/value_from.hpp b/include/boost/json/detail/value_from.hpp index 7f2e77c9..c14178bc 100644 --- a/include/boost/json/detail/value_from.hpp +++ b/include/boost/json/detail/value_from.hpp @@ -83,11 +83,13 @@ tag_invoke( // Generic conversions // string-like types +// NOTE: original check for size used is_convertible but +// MSVC-140 selects wrong specialisation if used template, const char*, std::size_t>::value && - std::is_convertible().data()), const char*>::value && - std::is_convertible().size()), - std::size_t>::value>::type* = nullptr> + std::is_convertible().data()), const char*>::value && + std::is_integral().size())>::value +>::type* = nullptr> void value_from_generic( value& jv, diff --git a/include/boost/json/detail/value_to.hpp b/include/boost/json/detail/value_to.hpp index 2708451a..bdf5401e 100644 --- a/include/boost/json/detail/value_to.hpp +++ b/include/boost/json/detail/value_to.hpp @@ -100,11 +100,13 @@ tag_invoke( // Use generic conversion // string-like types +// NOTE: original check for size used is_convertible but +// MSVC-140 selects wrong specialisation if used template::value && - std::is_convertible().data()), const char*>::value && - std::is_convertible().size()), - std::size_t>::value>::type* = nullptr> + std::is_convertible().data()), const char*>::value && + std::is_integral().size())>::value +>::type* = nullptr> T value_to_generic( const value& jv,