From b9416a26aa42b0a967bda6b84b0ef5baa188c516 Mon Sep 17 00:00:00 2001 From: Francois Chabot Date: Wed, 27 May 2020 13:21:23 -0400 Subject: [PATCH] correct ADL lookup of arrays on Mac and Windows --- .../nlohmann/detail/input/input_adapters.hpp | 25 +++---------------- single_include/nlohmann/json.hpp | 25 +++---------------- 2 files changed, 8 insertions(+), 42 deletions(-) diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index 9d868202..67a7f0d0 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -365,6 +365,10 @@ typename iterator_input_adapter_factory::adapter_type input_adapte template auto input_adapter(const ContainerType& container) -> decltype(input_adapter(begin(container), end(container))) { + // Enable ADL + using std::begin; + using std::end; + return input_adapter(begin(container), end(container)); } @@ -416,15 +420,6 @@ class span_input_adapter span_input_adapter(CharT b, std::size_t l) : ia(reinterpret_cast(b), reinterpret_cast(b) + l) {} - template::value and - std::is_integral::type>::value and - sizeof(typename std::remove_pointer::type) == 1, - int>::type = 0> - span_input_adapter(CharT b) - : span_input_adapter(b, std::strlen(reinterpret_cast(b))) {} - template::iterator_category, std::random_access_iterator_tag>::value, @@ -432,18 +427,6 @@ class span_input_adapter span_input_adapter(IteratorType first, IteratorType last) : ia(input_adapter(first, last)) {} - template - span_input_adapter(T (&array)[N]) - : span_input_adapter(std::begin(array), std::end(array)) {} - - /// input adapter for contiguous container - template::value and - std::is_base_of()))>::iterator_category>::value, - int>::type = 0> - span_input_adapter(const ContiguousContainer& c) - : span_input_adapter(std::begin(c), std::end(c)) {} - contiguous_bytes_input_adapter&& get() { return std::move(ia); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 8f9c103e..5240aedd 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -4787,6 +4787,10 @@ typename iterator_input_adapter_factory::adapter_type input_adapte template auto input_adapter(const ContainerType& container) -> decltype(input_adapter(begin(container), end(container))) { + // Enable ADL + using std::begin; + using std::end; + return input_adapter(begin(container), end(container)); } @@ -4838,15 +4842,6 @@ class span_input_adapter span_input_adapter(CharT b, std::size_t l) : ia(reinterpret_cast(b), reinterpret_cast(b) + l) {} - template::value and - std::is_integral::type>::value and - sizeof(typename std::remove_pointer::type) == 1, - int>::type = 0> - span_input_adapter(CharT b) - : span_input_adapter(b, std::strlen(reinterpret_cast(b))) {} - template::iterator_category, std::random_access_iterator_tag>::value, @@ -4854,18 +4849,6 @@ class span_input_adapter span_input_adapter(IteratorType first, IteratorType last) : ia(input_adapter(first, last)) {} - template - span_input_adapter(T (&array)[N]) - : span_input_adapter(std::begin(array), std::end(array)) {} - - /// input adapter for contiguous container - template::value and - std::is_base_of()))>::iterator_category>::value, - int>::type = 0> - span_input_adapter(const ContiguousContainer& c) - : span_input_adapter(std::begin(c), std::end(c)) {} - contiguous_bytes_input_adapter&& get() { return std::move(ia);