Skip to content

Commit 36f6199

Browse files
committed
Fix string conversion under Clang
1 parent bd05c7a commit 36f6199

3 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/json.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ json::object_t json::get() const
442442
}
443443
}
444444

445-
json::operator const std::string() const
445+
json::operator std::string() const
446446
{
447447
return get<std::string>();
448448
}

src/json.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class json
175175
T get() const;
176176

177177
/// implicit conversion to string representation
178-
operator const std::string() const;
178+
operator std::string() const;
179179
/// implicit conversion to integer (only for numbers)
180180
operator int() const;
181181
/// implicit conversion to double (only for numbers)

test/json_unit.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ TEST_CASE("string")
773773
CHECK_NOTHROW(auto v = j.get<json::array_t>());
774774
CHECK_THROWS_AS(auto v = j.get<json::object_t>(), std::logic_error);
775775
CHECK_NOTHROW(auto v = j.get<std::string>());
776+
CHECK_NOTHROW(auto v = static_cast<std::string>(j));
776777
CHECK_THROWS_AS(auto v = j.get<bool>(), std::logic_error);
777778
CHECK_THROWS_AS(auto v = j.get<int>(), std::logic_error);
778779
CHECK_THROWS_AS(auto v = j.get<double>(), std::logic_error);

0 commit comments

Comments
 (0)