-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C++17's ambiguous conversion #586
Labels
confirmed
kind: bug
solution: proposed fix
a fix for the issue has been proposed and waits for confirmation
Milestone
Comments
This seems related to #464. |
Checked with the latest GCC trunk version:
|
Thanks for the replying.This error message you posted is exactly what I had. |
This fixes the issue: diff --git a/src/json.hpp b/src/json.hpp
index 85d559d7..7bfb7359 100644
--- a/src/json.hpp
+++ b/src/json.hpp
@@ -3742,7 +3742,7 @@ class basic_json
#ifndef _MSC_VER // fix for issue #167 operator<< ambiguity under VS2015
and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
#endif
-#if defined(_MSC_VER) && _MSC_VER >1900 && defined(_HAS_CXX17) && _HAS_CXX17 == 1 // fix for issue #464
+#if (defined(__cplusplus) && __cplusplus == 201703L) || (defined(_MSC_VER) && _MSC_VER >1900 && defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
and not std::is_same<ValueType, typename std::string_view>::value
#endif
, int >::type = 0 > |
nlohmann
added a commit
that referenced
this issue
May 20, 2017
nlohmann
added
the
solution: proposed fix
a fix for the issue has been proposed and waits for confirmation
label
May 20, 2017
thanks for the fix. |
Very good point. I shall fix this. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
confirmed
kind: bug
solution: proposed fix
a fix for the issue has been proposed and waits for confirmation
In c++ 17, std::string_view can be converted to std::string implicitly which leads to a problem that in c++17 mode , a json object cannot be assigned to a string due to ambiguous assigning conversion path ( json --> string and json --> string_view --> string).
In gcc 7.1 such code produces a compilation error width -std=c++1z.
code:
So, is it possible to remove the conversion to string specifically in c++17 mode to let the compiler select the json--> string_view --> string path ?
The text was updated successfully, but these errors were encountered: