diff --git a/include/nlohmann/detail/iterators/iteration_proxy.hpp b/include/nlohmann/detail/iterators/iteration_proxy.hpp
index c61d9629..48927b01 100644
--- a/include/nlohmann/detail/iterators/iteration_proxy.hpp
+++ b/include/nlohmann/detail/iterators/iteration_proxy.hpp
@@ -12,7 +12,8 @@ namespace nlohmann
 {
 namespace detail
 {
-template<typename string_type>
+template<typename string_type, typename std::enable_if<
+             std::is_same<char, typename string_type::value_type>::value, int>::type = 0>
 void int_to_string( string_type& target, std::size_t value )
 {
     target = std::to_string(value);
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp
index cc822a54..69a4ec09 100644
--- a/single_include/nlohmann/json.hpp
+++ b/single_include/nlohmann/json.hpp
@@ -3650,7 +3650,8 @@ namespace nlohmann
 {
 namespace detail
 {
-template<typename string_type>
+template<typename string_type, typename std::enable_if<
+             std::is_same<char, typename string_type::value_type>::value, int>::type = 0>
 void int_to_string( string_type& target, std::size_t value )
 {
     target = std::to_string(value);