{"action":"opened","issue":{"url":"https://api.github.com/repos/jbcoe/polymorphic_value/issues/37","repository_url":"https://api.github.com/repos/jbcoe/polymorphic_value","labels_url":"https://api.github.com/repos/jbcoe/polymorphic_value/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/jbcoe/polymorphic_value/issues/37/comments","events_url":"https://api.github.com/repos/jbcoe/polymorphic_value/issues/37/events","html_url":"https://github.com/jbcoe/polymorphic_value/issues/37","id":274718304,"number":37,"title":"default_copy return type","user":{"login":"uecasm","id":539951,"avatar_url":"https://avatars1.githubusercontent.com/u/539951?v=4","gravatar_id":"","url":"https://api.github.com/users/uecasm","html_url":"https://github.com/uecasm","followers_url":"https://api.github.com/users/uecasm/followers","following_url":"https://api.github.com/users/uecasm/following{/other_user}","gists_url":"https://api.github.com/users/uecasm/gists{/gist_id}","starred_url":"https://api.github.com/users/uecasm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uecasm/subscriptions","organizations_url":"https://api.github.com/users/uecasm/orgs","repos_url":"https://api.github.com/users/uecasm/repos","events_url":"https://api.github.com/users/uecasm/events{/privacy}","received_events_url":"https://api.github.com/users/uecasm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-17T01:06:08Z","updated_at":"2017-11-17T01:06:08Z","closed_at":null,"author_association":"NONE","body":"Would it not be better to define this like so:\r\n\r\n    template <class T>\r\n    struct default_copy\r\n    {\r\n        unique_ptr<T> operator()(const T& t) const\r\n        {\r\n            return make_unique<T>(t);\r\n        }\r\n    };\r\n\r\nReturning a `unique_ptr` more accurately conveys the intent to create a new T and return ownership of it.\r\n\r\nOr perhaps even something like:\r\n\r\n    template <class T, class D = default_delete<T> >\r\n    struct default_copy\r\n    {\r\n        unique_ptr<T, D> operator()(const T& t, D d = D{}) const\r\n        {\r\n            return unique_ptr<T, D>(new T(t), std::move(d));\r\n        }\r\n    };\r\n\r\nThough I'm not sure if the extra complexity is worthwhile, and it has more potential for shooting yourself in the foot, so I prefer the former."}}
{"actor":{"display_login":"uecasm"}}