From c2e175763c7fb4137fc0b8ce6c07fc5e5a9928df Mon Sep 17 00:00:00 2001
From: Niels Lohmann <mail@nlohmann.me>
Date: Thu, 25 Oct 2018 22:47:08 +0200
Subject: [PATCH] :ok_hand: added another conversion function #1315

---
 include/nlohmann/detail/output/binary_writer.hpp | 11 +++++++++++
 single_include/nlohmann/json.hpp                 | 11 +++++++++++
 2 files changed, 22 insertions(+)

diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp
index 133b60f8..4e969158 100644
--- a/include/nlohmann/detail/output/binary_writer.hpp
+++ b/include/nlohmann/detail/output/binary_writer.hpp
@@ -965,6 +965,17 @@ class binary_writer
         return x;
     }
 
+    template < typename InputCharType, typename C = CharType,
+               enable_if_t <
+                   std::is_signed<C>::value and
+                   std::is_signed<char>::value and
+                   std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
+                   > * = nullptr >
+    static constexpr CharType to_char_type(InputCharType x) noexcept
+    {
+        return x;
+    }
+
   private:
     /// whether we can assume little endianess
     const bool is_little_endian = binary_reader<BasicJsonType>::little_endianess();
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp
index 2fd5144e..d11c07d9 100644
--- a/single_include/nlohmann/json.hpp
+++ b/single_include/nlohmann/json.hpp
@@ -9010,6 +9010,17 @@ class binary_writer
         return x;
     }
 
+    template < typename InputCharType, typename C = CharType,
+               enable_if_t <
+                   std::is_signed<C>::value and
+                   std::is_signed<char>::value and
+                   std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
+                   > * = nullptr >
+    static constexpr CharType to_char_type(InputCharType x) noexcept
+    {
+        return x;
+    }
+
   private:
     /// whether we can assume little endianess
     const bool is_little_endian = binary_reader<BasicJsonType>::little_endianess();