-
-
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
map string string fails to compile #176
Comments
Just to make sure: in your comment, you mean // if I change to map<std::string,std::string> then it compiles and not // if I change to map<string,int> then it compiles |
no, I mean that if I change to:
then it compiles as it should |
I have not analyzed the bug deeper, but the issue seems not to be type alias. The following code also fails to compile: #include <json.hpp>
using nlohmann::json;
int main()
{
std::map<std::string, std::string> t;
// this works
json s = t;
// the fails
s.get<std::map<std::string, std::string>>();
} |
Same error with a more concise example: #include <json.hpp>
using nlohmann::json;
int main()
{
json s = json::object();
std::map<std::string, std::string> m = s;
} Error:
|
This function triggered the error: /// get an object (explicit)
template <class T, typename
std::enable_if<
std::is_convertible<typename object_t::key_type, typename T::key_type>::value and
std::is_convertible<basic_json_t, typename T::mapped_type>::value
, int>::type = 0>
T get_impl(T*) const This function tries to return an object of type #include <json.hpp>
using nlohmann::json;
int main()
{
json::object_t s;
std::map<std::string, std::string>(s.begin(), s.end());
} For the last line's constructor, the documentation states for the iterators:
This can reduce the example to #include <json.hpp>
using nlohmann::json;
int main()
{
json::object_t::value_type s;
std::map<std::string, std::string>::value_type t(s);
} |
Further reduction: #include <json.hpp>
using nlohmann::json;
int main()
{
json s;
std::string t(s);
} error:
|
Found this comment on StackOverflow, quoting cppreference:
Indeed, |
I fail to compile this piece of code:
The text was updated successfully, but these errors were encountered: