{"action":"created","issue":{"url":"https://api.github.com/repos/nlohmann/json/issues/174","labels_url":"https://api.github.com/repos/nlohmann/json/issues/174/labels{/name}","comments_url":"https://api.github.com/repos/nlohmann/json/issues/174/comments","events_url":"https://api.github.com/repos/nlohmann/json/issues/174/events","html_url":"https://github.com/nlohmann/json/issues/174","id":125608432,"number":174,"title":"In basic_json::basic_json(const CompatibleArrayType& val), the requirement of CompatibleArrayType is not strict enough.","user":{"login":"mysyljr","id":3873706,"avatar_url":"https://avatars.githubusercontent.com/u/3873706?v=3","gravatar_id":"","url":"https://api.github.com/users/mysyljr","html_url":"https://github.com/mysyljr","followers_url":"https://api.github.com/users/mysyljr/followers","following_url":"https://api.github.com/users/mysyljr/following{/other_user}","gists_url":"https://api.github.com/users/mysyljr/gists{/gist_id}","starred_url":"https://api.github.com/users/mysyljr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mysyljr/subscriptions","organizations_url":"https://api.github.com/users/mysyljr/orgs","repos_url":"https://api.github.com/users/mysyljr/repos","events_url":"https://api.github.com/users/mysyljr/events{/privacy}","received_events_url":"https://api.github.com/users/mysyljr/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nlohmann/json/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-08T13:02:20Z","updated_at":"2016-01-10T20:23:30Z","closed_at":null,"body":"This is a question Ralated to #167 : \r\nIn basic_json::basic_json(const CompatibleArrayType& val), the requirement of CompatibleArrayType is not strict enough. \r\n```c++                  \r\ntemplate <class CompatibleArrayType, typename\r\n              std::enable_if<\r\n                  not std::is_same<CompatibleArrayType, typename basic_json_t::iterator>::value and\r\n                  not std::is_same<CompatibleArrayType, typename basic_json_t::const_iterator>::value and\r\n                  not std::is_same<CompatibleArrayType, typename basic_json_t::reverse_iterator>::value and\r\n                  not std::is_same<CompatibleArrayType, typename basic_json_t::const_reverse_iterator>::value and\r\n                  not std::is_same<CompatibleArrayType, typename array_t::iterator>::value and\r\n                  not std::is_same<CompatibleArrayType, typename array_t::const_iterator>::value and\r\n                  std::is_constructible<basic_json, typename CompatibleArrayType::value_type>::value, int>::type\r\n              = 0>\r\n    basic_json(const CompatibleArrayType& val)\r\n        : m_type(value_t::array)\r\n    {\r\n        using std::begin;\r\n        using std::end;\r\n        m_value.array = create<array_t>(begin(val), end(val));\r\n    }\r\n```\r\nTemplate constructor of basic_json_t above can receive any type that has a type member value_type which can be used as the only parameter in one of basic_json_t's constructors and regard that type as a CompatibleArrayType.\r\nI think the scope of the target types is too much wide, though it excludes some of the types already meet the requirement but are not CompatibleArrayType, still not fine with 3rd party types. "},"comment":{"url":"https://api.github.com/repos/nlohmann/json/issues/comments/170390206","html_url":"https://github.com/nlohmann/json/issues/174#issuecomment-170390206","issue_url":"https://api.github.com/repos/nlohmann/json/issues/174","id":170390206,"user":{"login":"nlohmann","id":159488,"avatar_url":"https://avatars.githubusercontent.com/u/159488?v=3","gravatar_id":"","url":"https://api.github.com/users/nlohmann","html_url":"https://github.com/nlohmann","followers_url":"https://api.github.com/users/nlohmann/followers","following_url":"https://api.github.com/users/nlohmann/following{/other_user}","gists_url":"https://api.github.com/users/nlohmann/gists{/gist_id}","starred_url":"https://api.github.com/users/nlohmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nlohmann/subscriptions","organizations_url":"https://api.github.com/users/nlohmann/orgs","repos_url":"https://api.github.com/users/nlohmann/repos","events_url":"https://api.github.com/users/nlohmann/events{/privacy}","received_events_url":"https://api.github.com/users/nlohmann/received_events","type":"User","site_admin":false},"created_at":"2016-01-10T20:23:29Z","updated_at":"2016-01-10T20:23:29Z","body":"The code was inspired by some similar constructor from [dropbox/json11](https://github.com/dropbox/json11). In fact, I only added constraints to make the code compile in my setting.\r\n\r\n@mysyljr, do you have an example where the code actually breaks?"}}