string_utils.hpp 840 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // __ _____ _____ _____
  2. // __| | __| | | | JSON for Modern C++
  3. // | | |__ | | | | | | version 3.12.0
  4. // |_____|_____|_____|_|___| https://github.com/nlohmann/json
  5. //
  6. // SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
  7. // SPDX-License-Identifier: MIT
  8. #pragma once
  9. #include <cstddef> // size_t
  10. #include <string> // string, to_string
  11. #include <nlohmann/detail/abi_macros.hpp>
  12. NLOHMANN_JSON_NAMESPACE_BEGIN
  13. namespace detail
  14. {
  15. template<typename StringType>
  16. void int_to_string(StringType& target, std::size_t value)
  17. {
  18. // For ADL
  19. using std::to_string;
  20. target = to_string(value);
  21. }
  22. template<typename StringType>
  23. StringType to_string(std::size_t value)
  24. {
  25. StringType result;
  26. int_to_string(result, value);
  27. return result;
  28. }
  29. } // namespace detail
  30. NLOHMANN_JSON_NAMESPACE_END