{"action":"created","issue":{"url":"https://api.github.com/repos/nlohmann/json/issues/861","repository_url":"https://api.github.com/repos/nlohmann/json","labels_url":"https://api.github.com/repos/nlohmann/json/issues/861/labels{/name}","comments_url":"https://api.github.com/repos/nlohmann/json/issues/861/comments","events_url":"https://api.github.com/repos/nlohmann/json/issues/861/events","html_url":"https://github.com/nlohmann/json/issues/861","id":280136984,"number":861,"title":"Casting to std::string not working in VS2015","user":{"login":"jojastahl","id":15796520,"avatar_url":"https://avatars0.githubusercontent.com/u/15796520?v=4","gravatar_id":"","url":"https://api.github.com/users/jojastahl","html_url":"https://github.com/jojastahl","followers_url":"https://api.github.com/users/jojastahl/followers","following_url":"https://api.github.com/users/jojastahl/following{/other_user}","gists_url":"https://api.github.com/users/jojastahl/gists{/gist_id}","starred_url":"https://api.github.com/users/jojastahl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jojastahl/subscriptions","organizations_url":"https://api.github.com/users/jojastahl/orgs","repos_url":"https://api.github.com/users/jojastahl/repos","events_url":"https://api.github.com/users/jojastahl/events{/privacy}","received_events_url":"https://api.github.com/users/jojastahl/received_events","type":"User","site_admin":false},"labels":[{"id":296080787,"url":"https://api.github.com/repos/nlohmann/json/labels/platform:%20visual%20studio","name":"platform: visual studio","color":"eb6420","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-12-07T13:51:31Z","updated_at":"2017-12-08T09:18:29Z","closed_at":null,"author_association":"NONE","body":"The following doesn't compile in Visual Studio 2015 Update 3:\r\n\r\n```C++\r\n      json o = { { \"name\", \"value\" } };\r\n      std::string s1;\r\n      s1 = static_cast<std::string>(o[\"name\"]);  // Failing line\r\n```\r\n\r\nIt gives the following error:\r\n\r\n> error C2440: 'static_cast': cannot convert from 'nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>' to 'std::string'\r\n> note: No constructor could take the source type, or constructor overload resolution was ambiguous\r\n \r\nI tried this with the develop branch aswell as the 2.1.1 release.\r\nI'm using Visual Studio 2015 Update 3 with compiler version 19.00.24215.1 for x86\r\n\r\nThis is related to #188 and #167. I have to exclude the _MSC_VER check, so that the condition included in the VS build, too. However, this condition has been introduced to fix #167 as far as I understand. Was #167 a problem in VS2015 pre Update 3 only, or hasn't a test been added for #167? I can compile and run all unit-xxx tests with the check removed."},"comment":{"url":"https://api.github.com/repos/nlohmann/json/issues/comments/350214338","html_url":"https://github.com/nlohmann/json/issues/861#issuecomment-350214338","issue_url":"https://api.github.com/repos/nlohmann/json/issues/861","id":350214338,"user":{"login":"jojastahl","id":15796520,"avatar_url":"https://avatars0.githubusercontent.com/u/15796520?v=4","gravatar_id":"","url":"https://api.github.com/users/jojastahl","html_url":"https://github.com/jojastahl","followers_url":"https://api.github.com/users/jojastahl/followers","following_url":"https://api.github.com/users/jojastahl/following{/other_user}","gists_url":"https://api.github.com/users/jojastahl/gists{/gist_id}","starred_url":"https://api.github.com/users/jojastahl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jojastahl/subscriptions","organizations_url":"https://api.github.com/users/jojastahl/orgs","repos_url":"https://api.github.com/users/jojastahl/repos","events_url":"https://api.github.com/users/jojastahl/events{/privacy}","received_events_url":"https://api.github.com/users/jojastahl/received_events","type":"User","site_admin":false},"created_at":"2017-12-08T09:18:29Z","updated_at":"2017-12-08T09:18:29Z","author_association":"NONE","body":"So why this compiles in VS, if the condition \r\n```C++\r\nand not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value\r\n``` \r\nis included for `basic_json::operator ValueType() const`?\r\n\r\nWhen you compiled with GCC, did you explicitly exclude this condition (as it is only excluded if _MSC_VER is defined, which shouldn't be the case for GCC)? If no, VS and GCC are behaving diffrently here.\r\n\r\nNevertheless I do not understand the behavior. I thought that the compiler would use the `operator ValueType() const` if I do `static_cast<Type>(json)`, provided that it is not explicitly disabled by SFINAE. But it seems it is ignoring it and choosing the `Type` constructor instead."}}
{"actor":{"display_login":"jojastahl"}}