Merge pull request #26 from wancw/fix_clang_string_casting
Fix string conversion under Clang
This commit is contained in:
commit
dcf71748a6
3 changed files with 3 additions and 2 deletions
|
@ -442,7 +442,7 @@ json::object_t json::get() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
json::operator const std::string() const
|
json::operator std::string() const
|
||||||
{
|
{
|
||||||
return get<std::string>();
|
return get<std::string>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ class json
|
||||||
T get() const;
|
T get() const;
|
||||||
|
|
||||||
/// implicit conversion to string representation
|
/// implicit conversion to string representation
|
||||||
operator const std::string() const;
|
operator std::string() const;
|
||||||
/// implicit conversion to integer (only for numbers)
|
/// implicit conversion to integer (only for numbers)
|
||||||
operator int() const;
|
operator int() const;
|
||||||
/// implicit conversion to double (only for numbers)
|
/// implicit conversion to double (only for numbers)
|
||||||
|
|
|
@ -773,6 +773,7 @@ TEST_CASE("string")
|
||||||
CHECK_NOTHROW(auto v = j.get<json::array_t>());
|
CHECK_NOTHROW(auto v = j.get<json::array_t>());
|
||||||
CHECK_THROWS_AS(auto v = j.get<json::object_t>(), std::logic_error);
|
CHECK_THROWS_AS(auto v = j.get<json::object_t>(), std::logic_error);
|
||||||
CHECK_NOTHROW(auto v = j.get<std::string>());
|
CHECK_NOTHROW(auto v = j.get<std::string>());
|
||||||
|
CHECK_NOTHROW(auto v = static_cast<std::string>(j));
|
||||||
CHECK_THROWS_AS(auto v = j.get<bool>(), std::logic_error);
|
CHECK_THROWS_AS(auto v = j.get<bool>(), std::logic_error);
|
||||||
CHECK_THROWS_AS(auto v = j.get<int>(), std::logic_error);
|
CHECK_THROWS_AS(auto v = j.get<int>(), std::logic_error);
|
||||||
CHECK_THROWS_AS(auto v = j.get<double>(), std::logic_error);
|
CHECK_THROWS_AS(auto v = j.get<double>(), std::logic_error);
|
||||||
|
|
Loading…
Reference in a new issue