{"action":"opened","issue":{"url":"https://api.github.com/repos/boost-experimental/di/issues/221","repository_url":"https://api.github.com/repos/boost-experimental/di","labels_url":"https://api.github.com/repos/boost-experimental/di/issues/221/labels{/name}","comments_url":"https://api.github.com/repos/boost-experimental/di/issues/221/comments","events_url":"https://api.github.com/repos/boost-experimental/di/issues/221/events","html_url":"https://github.com/boost-experimental/di/issues/221","id":163653156,"number":221,"title":"Uninitialized unique_ptr","user":{"login":"shirolimit","id":8833257,"avatar_url":"https://avatars.githubusercontent.com/u/8833257?v=3","gravatar_id":"","url":"https://api.github.com/users/shirolimit","html_url":"https://github.com/shirolimit","followers_url":"https://api.github.com/users/shirolimit/followers","following_url":"https://api.github.com/users/shirolimit/following{/other_user}","gists_url":"https://api.github.com/users/shirolimit/gists{/gist_id}","starred_url":"https://api.github.com/users/shirolimit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shirolimit/subscriptions","organizations_url":"https://api.github.com/users/shirolimit/orgs","repos_url":"https://api.github.com/users/shirolimit/repos","events_url":"https://api.github.com/users/shirolimit/events{/privacy}","received_events_url":"https://api.github.com/users/shirolimit/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-04T10:59:51Z","updated_at":"2016-07-04T10:59:51Z","closed_at":null,"body":"Hi, Krzysztof!\r\n\r\nWhy I cannot create object with unique_ptr member, that is not initialized explicitly in ctor. \r\nIt can be initialized later for example using setter.\r\nHere is the code:\r\n\r\n```\r\nclass Interface1 {};\r\n\r\nclass Interface2 {};\r\n\r\nclass Impl1: public Interface1 {};\r\n\r\nclass Impl2: public Interface2 {};\r\n\r\nclass App\r\n{\r\npublic:\r\n    explicit App(Interface1* if1)\r\n        : _if1(if1)\r\n    {\r\n    }\r\n\r\n    virtual ~App() noexcept = default;\r\n\r\nprivate:\r\n    Interface1* _if1;\r\n    std::unique_ptr<Interface2> _if2;\r\n};\r\n\r\nnamespace di = boost::di;\r\n\r\nint main(int argc, char* argv[])\r\n{\r\n\r\n    auto injector = di::make_injector(\r\n        di::bind<Interface1>.to<Impl1>()\r\n    );\r\n    auto house = injector.create<App*>();\r\n\r\n    return 0;\r\n}\r\n```\r\n\r\nCompiler output is as follows (GCC 5.2.1):\r\n\r\n`error(_ = \"type is not bound, did you forget to add: 'di::bind<interface>.to<implementation>()'?\");`\r\n\r\nIf I change _if2 type to plain pointer or shared_ptr, the code compiles without errors."}}
{"actor":{"display_login":"shirolimit"}}