diff --git a/include/nlohmann/detail/iterators/iteration_proxy.hpp b/include/nlohmann/detail/iterators/iteration_proxy.hpp
index 30c5e0c5..8c54746f 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
 {
-void int_to_string( std::string& target, int value )
+template<typename string_type>
+void int_to_string( string_type& target, int value )
 {
     target = std::to_string(value);
 }
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp
index 9b4df8a1..84fa6882 100644
--- a/single_include/nlohmann/json.hpp
+++ b/single_include/nlohmann/json.hpp
@@ -3186,7 +3186,8 @@ namespace nlohmann
 {
 namespace detail
 {
-void int_to_string( std::string& target, int value )
+template<typename string_type>
+void int_to_string( string_type& target, int value )
 {
     target = std::to_string(value);
 }