From b9416a26aa42b0a967bda6b84b0ef5baa188c516 Mon Sep 17 00:00:00 2001
From: Francois Chabot <francois@ai-r.com>
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<IteratorType>::adapter_type input_adapte
 template<typename ContainerType>
 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<const char*>(b), reinterpret_cast<const char*>(b) + l) {}
 
-    template<typename CharT,
-             typename std::enable_if<
-                 std::is_pointer<CharT>::value and
-                 std::is_integral<typename std::remove_pointer<CharT>::type>::value and
-                 sizeof(typename std::remove_pointer<CharT>::type) == 1,
-                 int>::type = 0>
-    span_input_adapter(CharT b)
-        : span_input_adapter(b, std::strlen(reinterpret_cast<const char*>(b))) {}
-
     template<class IteratorType,
              typename std::enable_if<
                  std::is_same<typename iterator_traits<IteratorType>::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<class T, std::size_t N>
-    span_input_adapter(T (&array)[N])
-        : span_input_adapter(std::begin(array), std::end(array)) {}
-
-    /// input adapter for contiguous container
-    template<class ContiguousContainer, typename
-             std::enable_if<not std::is_pointer<ContiguousContainer>::value and
-                            std::is_base_of<std::random_access_iterator_tag, typename iterator_traits<decltype(std::begin(std::declval<ContiguousContainer const>()))>::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<IteratorType>::adapter_type input_adapte
 template<typename ContainerType>
 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<const char*>(b), reinterpret_cast<const char*>(b) + l) {}
 
-    template<typename CharT,
-             typename std::enable_if<
-                 std::is_pointer<CharT>::value and
-                 std::is_integral<typename std::remove_pointer<CharT>::type>::value and
-                 sizeof(typename std::remove_pointer<CharT>::type) == 1,
-                 int>::type = 0>
-    span_input_adapter(CharT b)
-        : span_input_adapter(b, std::strlen(reinterpret_cast<const char*>(b))) {}
-
     template<class IteratorType,
              typename std::enable_if<
                  std::is_same<typename iterator_traits<IteratorType>::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<class T, std::size_t N>
-    span_input_adapter(T (&array)[N])
-        : span_input_adapter(std::begin(array), std::end(array)) {}
-
-    /// input adapter for contiguous container
-    template<class ContiguousContainer, typename
-             std::enable_if<not std::is_pointer<ContiguousContainer>::value and
-                            std::is_base_of<std::random_access_iterator_tag, typename iterator_traits<decltype(std::begin(std::declval<ContiguousContainer const>()))>::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);