{"action":"created","issue":{"url":"https://api.github.com/repos/nlohmann/json/issues/448","repository_url":"https://api.github.com/repos/nlohmann/json","labels_url":"https://api.github.com/repos/nlohmann/json/issues/448/labels{/name}","comments_url":"https://api.github.com/repos/nlohmann/json/issues/448/comments","events_url":"https://api.github.com/repos/nlohmann/json/issues/448/events","html_url":"https://github.com/nlohmann/json/issues/448","id":207045180,"number":448,"title":"Json should not be constructible with 'json*'","user":{"login":"jaredgrubb","id":1256381,"avatar_url":"https://avatars.githubusercontent.com/u/1256381?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredgrubb","html_url":"https://github.com/jaredgrubb","followers_url":"https://api.github.com/users/jaredgrubb/followers","following_url":"https://api.github.com/users/jaredgrubb/following{/other_user}","gists_url":"https://api.github.com/users/jaredgrubb/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredgrubb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredgrubb/subscriptions","organizations_url":"https://api.github.com/users/jaredgrubb/orgs","repos_url":"https://api.github.com/users/jaredgrubb/repos","events_url":"https://api.github.com/users/jaredgrubb/events{/privacy}","received_events_url":"https://api.github.com/users/jaredgrubb/received_events","type":"User","site_admin":false},"labels":[{"id":46374231,"url":"https://api.github.com/repos/nlohmann/json/labels/kind:%20bug","name":"kind: bug","color":"fc2929","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-02-12T11:46:22Z","updated_at":"2017-02-14T17:08:25Z","closed_at":null,"body":"I had something like this:\r\n```\r\n        json* p;\r\n        json j(p);\r\n```\r\nThis was a bug (I need to dereference the pointer), but json constructor accepts it as a boolean type because it's finding this overload:\r\n```\r\ntemplate<typename BasicJsonType>\r\nvoid to_json(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept\r\n```\r\n\r\nThe problem with 'bool' is that it captures a lot of things. Classes with 'operator bool()' are also being caught. \r\n\r\nI can think of some simple changes (SFINAE something), but I'm not sure how well they work with arbitrary BasicJsonType's."},"comment":{"url":"https://api.github.com/repos/nlohmann/json/issues/comments/279770300","html_url":"https://github.com/nlohmann/json/issues/448#issuecomment-279770300","issue_url":"https://api.github.com/repos/nlohmann/json/issues/448","id":279770300,"user":{"login":"jaredgrubb","id":1256381,"avatar_url":"https://avatars.githubusercontent.com/u/1256381?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredgrubb","html_url":"https://github.com/jaredgrubb","followers_url":"https://api.github.com/users/jaredgrubb/followers","following_url":"https://api.github.com/users/jaredgrubb/following{/other_user}","gists_url":"https://api.github.com/users/jaredgrubb/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredgrubb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredgrubb/subscriptions","organizations_url":"https://api.github.com/users/jaredgrubb/orgs","repos_url":"https://api.github.com/users/jaredgrubb/repos","events_url":"https://api.github.com/users/jaredgrubb/events{/privacy}","received_events_url":"https://api.github.com/users/jaredgrubb/received_events","type":"User","site_admin":false},"created_at":"2017-02-14T17:08:25Z","updated_at":"2017-02-14T17:08:25Z","body":"I have done this and it seems to work:\r\n```\r\n-template<typename BasicJsonType>\r\n-void to_json(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept\r\n+template<typename BasicJsonType, typename T,\r\n+    enable_if_t<std::is_same<std::decay_t<T>, typename BasicJsonType::boolean_t>::value, int> = 0>\r\n+void to_json(BasicJsonType& j, T b) noexcept\r\n```\r\n\r\nI'm not 100% that the decay is necessary."}}
{"actor":{"display_login":"jaredgrubb"}}