From dc7f80581c90ab8a8b4e609068c18895b9b3472e Mon Sep 17 00:00:00 2001 From: Stephane Janel Date: Thu, 11 Feb 2021 23:44:46 +0100 Subject: [PATCH] Fix compilation error that can occur with custom string not implicitely convertible to std::string --- include/nlohmann/json.hpp | 4 ++-- single_include/nlohmann/json.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 7b44c0ea3..8e7f2a15f 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3499,7 +3499,7 @@ class basic_json JSON_CATCH (std::out_of_range&) { // create better exception explanation - JSON_THROW(out_of_range::create(403, "key '" + key + "' not found", *this)); + JSON_THROW(out_of_range::create(403, "key '" + std::string(key.begin(), key.end()) + "' not found", *this)); } } else @@ -3550,7 +3550,7 @@ class basic_json JSON_CATCH (std::out_of_range&) { // create better exception explanation - JSON_THROW(out_of_range::create(403, "key '" + key + "' not found", *this)); + JSON_THROW(out_of_range::create(403, "key '" + std::string(key.begin(), key.end()) + "' not found", *this)); } } else diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index a83971da2..2480a3384 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -20282,7 +20282,7 @@ class basic_json JSON_CATCH (std::out_of_range&) { // create better exception explanation - JSON_THROW(out_of_range::create(403, "key '" + key + "' not found", *this)); + JSON_THROW(out_of_range::create(403, "key '" + std::string(key.begin(), key.end()) + "' not found", *this)); } } else @@ -20333,7 +20333,7 @@ class basic_json JSON_CATCH (std::out_of_range&) { // create better exception explanation - JSON_THROW(out_of_range::create(403, "key '" + key + "' not found", *this)); + JSON_THROW(out_of_range::create(403, "key '" + std::string(key.begin(), key.end()) + "' not found", *this)); } } else