diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 8f4882fd5..cff017725 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3860,7 +3860,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec detail::is_usable_as_key_type::value > ... > string_t value(const KeyType& key, const char* default_value) const { +#ifdef JSON_HAS_CPP_17 + return value(key, std::string_view(default_value)); +#else return value(key, string_t(default_value)); +#endif } /*! diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 866fcb26e..d787a306d 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -20907,7 +20907,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec detail::is_usable_as_key_type::value > ... > string_t value(const KeyType& key, const char* default_value) const { +#ifdef JSON_HAS_CPP_17 + return value(key, std::string_view(default_value)); +#else return value(key, string_t(default_value)); +#endif } /*!