Open
Description
Describe the bug
As it stands, we cannot write code like:
error_code write(std::ostream& in, const string_view s) noexcept; // 1
error_code write(std::ostream& in, const Json::Value& o) noexcept;
Because the call to '1' this is ambiguous:
write(in, "foo"s);
The problem is that C++ detects that it can automagically convert "foo"s
to either a string_view
OR a Json::Value
.
It's an annoying reality that explicit
isn't the default for constructors. It should be. Be that as it may, Jsoncpp
would play nicer if it did use explicit
.
To Reproduce
Steps to reproduce the behavior:
- See code snippets above.
Expected behavior
A clear and concise description of what you expected to happen.
An error message like:
serialize.cpp:343:12: error: call to 'write' is ambiguous
ec = write(in, str(o));
^~~~~
serialize.cpp:260:12: note: candidate function
error_code write(std::ostream& out, std::string_view x) noexcept
^
serialize.cpp:339:12: note: candidate function
error_code write(std::ostream& in, const Json::Value& o) noexcept
Desktop (please complete the following information):
Affects all version compiling under a conformant c++ compiler.