From 798e83a038ed7b0ae048ee508e7aaf0cfb62ceba Mon Sep 17 00:00:00 2001
From: Isaac Nickaein <nickaein.i@gmail.com>
Date: Fri, 21 Jun 2019 23:16:42 +0430
Subject: [PATCH] Workaround msvc2015 bug with explicit copy-constructor for
 const_iterator

---
 include/nlohmann/detail/iterators/iter_impl.hpp | 7 +++++++
 single_include/nlohmann/json.hpp                | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp
index 0b0282c2..8492c234 100644
--- a/include/nlohmann/detail/iterators/iter_impl.hpp
+++ b/include/nlohmann/detail/iterators/iter_impl.hpp
@@ -118,6 +118,13 @@ class iter_impl
           to iterator is not defined.
     */
 
+    /* We had to explicitly define the copy constructor for the const
+       case to circumvent a bug on msvc 2015 debug build.
+       More info: https://github.com/nlohmann/json/issues/1608
+     */
+    iter_impl(const iter_impl<const BasicJsonType>& other) noexcept
+        : m_object(other.m_object), m_it(other.m_it) {}
+
     /*!
     @brief converting constructor
     @param[in] other  non-const iterator to copy from
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp
index bb2dacbc..c652b35a 100644
--- a/single_include/nlohmann/json.hpp
+++ b/single_include/nlohmann/json.hpp
@@ -7821,6 +7821,13 @@ class iter_impl
           to iterator is not defined.
     */
 
+    /* We had to explicitly define the copy constructor for the const
+       case to circumvent a bug on msvc 2015 debug build.
+       More info: https://github.com/nlohmann/json/issues/1608
+     */
+    iter_impl(const iter_impl<const BasicJsonType>& other) noexcept
+        : m_object(other.m_object), m_it(other.m_it) {}
+
     /*!
     @brief converting constructor
     @param[in] other  non-const iterator to copy from