{"action":"created","comment":{"url":"https://api.github.com/repos/boost-experimental/di/pulls/comments/244585923","pull_request_review_id":188497698,"id":244585923,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NDU4NTkyMw==","diff_hunk":"@@ -0,0 +1,123 @@\n+//\n+// Copyright (c) 2012-2018 Kris Jusiak (kris at jusiak dot net)\n+//\n+// Distributed under the Boost Software License, Version 1.0.\n+// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n+//\n+#pragma once\n+\n+#include <cassert>\n+#include <functional>\n+#include <memory>\n+#include <typeindex>\n+#include <unordered_map>\n+\n+#include \"boost/di.hpp\"\n+\n+BOOST_DI_NAMESPACE_BEGIN\n+namespace extension {\n+\n+class runtime_provider : public config {\n+  using bindings_t = std::unordered_map<std::type_index, std::function<void *()>>;\n+\n+  class abstract_provider {\n+   public:\n+    explicit abstract_provider(const bindings_t &bindings) : bindings_{bindings} {}\n+\n+    template <class...>\n+    struct is_creatable {\n+      static constexpr auto value = true;\n+    };\n+\n+    template <class T, class TInitialization, class TMemory, class... TArgs>\n+    auto get(const TInitialization &, const TMemory &, TArgs &&... args) const {\n+      auto it = bindings_.find(std::type_index(typeid(T)));\n+      if (it == bindings_.end()) {\n+        return get<T>(std::integral_constant < bool,\n+                      !std::is_abstract<T>::value && std::is_constructible<T, TArgs...>::value > {},\n+                      std::forward<TArgs>(args)...);\n+      }\n+      return static_cast<T *>(it->second());\n+    }\n+\n+   private:\n+    template <class T, class... TArgs>\n+    auto get(std::true_type, TArgs &&... args) const {\n+      return new T{std::forward<TArgs>(args)...};\n+    }\n+\n+    template <class T, class... TArgs>\n+    auto get(std::false_type, TArgs &&...) const {\n+      assert(false && \"Type not bound!\");\n+      return static_cast<T *>(nullptr);\n+    }\n+\n+    const bindings_t &bindings_;\n+  };\n+\n+ public:\n+  auto provider(...) { return abstract_provider{bindings_}; }\n+  auto &bindings() { return bindings_; }\n+\n+ private:\n+  bindings_t bindings_{};\n+};\n+\n+class injector : public core::injector<runtime_provider> {\n+  template <class...>\n+  struct any;\n+\n+  template <class TParent, class TInjector>\n+  struct any<core::any_type_fwd<TParent>, TInjector> {\n+    using type = core::any_type<TParent, TInjector>;\n+  };\n+\n+  template <class TParent, class TInjector>\n+  struct any<core::any_type_ref_fwd<TParent>, TInjector> {\n+    using type = core::any_type_ref<TParent, TInjector>;\n+  };\n+\n+  template <class TParent, class TInjector>\n+  struct any<core::any_type_1st_fwd<TParent>, TInjector> {\n+    using type = core::any_type_1st<TParent, TInjector>;\n+  };\n+\n+  template <class TParent, class TInjector>\n+  struct any<core::any_type_1st_ref_fwd<TParent>, TInjector> {\n+    using type = core::any_type_1st_ref<TParent, TInjector>;\n+  };\n+\n+ public:\n+  injector() : core::injector<runtime_provider>{core::init{}} {}","path":"extension/include/boost/di/extension/providers/runtime_provider.hpp","position":91,"original_position":91,"commit_id":"b53af79d0527a104e14526c991af04a69ad522bd","original_commit_id":"b53af79d0527a104e14526c991af04a69ad522bd","user":{"login":"kanstantsin-chernik","id":3438115,"node_id":"MDQ6VXNlcjM0MzgxMTU=","avatar_url":"https://avatars1.githubusercontent.com/u/3438115?v=4","gravatar_id":"","url":"https://api.github.com/users/kanstantsin-chernik","html_url":"https://github.com/kanstantsin-chernik","followers_url":"https://api.github.com/users/kanstantsin-chernik/followers","following_url":"https://api.github.com/users/kanstantsin-chernik/following{/other_user}","gists_url":"https://api.github.com/users/kanstantsin-chernik/gists{/gist_id}","starred_url":"https://api.github.com/users/kanstantsin-chernik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kanstantsin-chernik/subscriptions","organizations_url":"https://api.github.com/users/kanstantsin-chernik/orgs","repos_url":"https://api.github.com/users/kanstantsin-chernik/repos","events_url":"https://api.github.com/users/kanstantsin-chernik/events{/privacy}","received_events_url":"https://api.github.com/users/kanstantsin-chernik/received_events","type":"User","site_admin":false},"body":"What if I want to override any other configs like `shared` scope instead of `singleton` by default?","created_at":"2018-12-31T13:44:53Z","updated_at":"2018-12-31T13:50:36Z","html_url":"https://github.com/boost-experimental/di/pull/372#discussion_r244585923","pull_request_url":"https://api.github.com/repos/boost-experimental/di/pulls/372","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/boost-experimental/di/pulls/comments/244585923"},"html":{"href":"https://github.com/boost-experimental/di/pull/372#discussion_r244585923"},"pull_request":{"href":"https://api.github.com/repos/boost-experimental/di/pulls/372"}}},"pull_request":{"url":"https://api.github.com/repos/boost-experimental/di/pulls/372","id":241524134,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQxNTI0MTM0","html_url":"https://github.com/boost-experimental/di/pull/372","diff_url":"https://github.com/boost-experimental/di/pull/372.diff","patch_url":"https://github.com/boost-experimental/di/pull/372.patch","issue_url":"https://api.github.com/repos/boost-experimental/di/issues/372","number":372,"state":"open","locked":false,"title":":new: [extension] Runtime provider/injector","user":{"login":"krzysztof-jusiak","id":1372601,"node_id":"MDQ6VXNlcjEzNzI2MDE=","avatar_url":"https://avatars2.githubusercontent.com/u/1372601?v=4","gravatar_id":"","url":"https://api.github.com/users/krzysztof-jusiak","html_url":"https://github.com/krzysztof-jusiak","followers_url":"https://api.github.com/users/krzysztof-jusiak/followers","following_url":"https://api.github.com/users/krzysztof-jusiak/following{/other_user}","gists_url":"https://api.github.com/users/krzysztof-jusiak/gists{/gist_id}","starred_url":"https://api.github.com/users/krzysztof-jusiak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krzysztof-jusiak/subscriptions","organizations_url":"https://api.github.com/users/krzysztof-jusiak/orgs","repos_url":"https://api.github.com/users/krzysztof-jusiak/repos","events_url":"https://api.github.com/users/krzysztof-jusiak/events{/privacy}","received_events_url":"https://api.github.com/users/krzysztof-jusiak/received_events","type":"User","site_admin":false},"body":"Problem:\r\n- There is no extension how to create fully runtime injector.\r\n\r\nSolution:\r\n- Add runtime_provider extension which allows to create and customize fully runtime injectors.\r\n\r\nProblem:\r\n-\r\n\r\nSolution:\r\n-\r\n\r\nIssue: #\r\n\r\nReviewers:\r\n@","created_at":"2018-12-31T04:12:26Z","updated_at":"2018-12-31T13:50:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ee7f7a31800a011e9fb4458a05c20a5a0fec2ffa","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/boost-experimental/di/pulls/372/commits","review_comments_url":"https://api.github.com/repos/boost-experimental/di/pulls/372/comments","review_comment_url":"https://api.github.com/repos/boost-experimental/di/pulls/comments{/number}","comments_url":"https://api.github.com/repos/boost-experimental/di/issues/372/comments","statuses_url":"https://api.github.com/repos/boost-experimental/di/statuses/b53af79d0527a104e14526c991af04a69ad522bd","head":{"label":"boost-experimental:runtime_injector","ref":"runtime_injector","sha":"b53af79d0527a104e14526c991af04a69ad522bd","user":{"login":"boost-experimental","id":16814575,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2ODE0NTc1","avatar_url":"https://avatars2.githubusercontent.com/u/16814575?v=4","gravatar_id":"","url":"https://api.github.com/users/boost-experimental","html_url":"https://github.com/boost-experimental","followers_url":"https://api.github.com/users/boost-experimental/followers","following_url":"https://api.github.com/users/boost-experimental/following{/other_user}","gists_url":"https://api.github.com/users/boost-experimental/gists{/gist_id}","starred_url":"https://api.github.com/users/boost-experimental/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boost-experimental/subscriptions","organizations_url":"https://api.github.com/users/boost-experimental/orgs","repos_url":"https://api.github.com/users/boost-experimental/repos","events_url":"https://api.github.com/users/boost-experimental/events{/privacy}","received_events_url":"https://api.github.com/users/boost-experimental/received_events","type":"Organization","site_admin":false},"repo":{"id":3250728,"node_id":"MDEwOlJlcG9zaXRvcnkzMjUwNzI4","name":"di","full_name":"boost-experimental/di","private":false,"owner":{"login":"boost-experimental","id":16814575,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2ODE0NTc1","avatar_url":"https://avatars2.githubusercontent.com/u/16814575?v=4","gravatar_id":"","url":"https://api.github.com/users/boost-experimental","html_url":"https://github.com/boost-experimental","followers_url":"https://api.github.com/users/boost-experimental/followers","following_url":"https://api.github.com/users/boost-experimental/following{/other_user}","gists_url":"https://api.github.com/users/boost-experimental/gists{/gist_id}","starred_url":"https://api.github.com/users/boost-experimental/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boost-experimental/subscriptions","organizations_url":"https://api.github.com/users/boost-experimental/orgs","repos_url":"https://api.github.com/users/boost-experimental/repos","events_url":"https://api.github.com/users/boost-experimental/events{/privacy}","received_events_url":"https://api.github.com/users/boost-experimental/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/boost-experimental/di","description":"[Boost].DI: C++14 Dependency Injection Library","fork":false,"url":"https://api.github.com/repos/boost-experimental/di","forks_url":"https://api.github.com/repos/boost-experimental/di/forks","keys_url":"https://api.github.com/repos/boost-experimental/di/keys{/key_id}","collaborators_url":"https://api.github.com/repos/boost-experimental/di/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/boost-experimental/di/teams","hooks_url":"https://api.github.com/repos/boost-experimental/di/hooks","issue_events_url":"https://api.github.com/repos/boost-experimental/di/issues/events{/number}","events_url":"https://api.github.com/repos/boost-experimental/di/events","assignees_url":"https://api.github.com/repos/boost-experimental/di/assignees{/user}","branches_url":"https://api.github.com/repos/boost-experimental/di/branches{/branch}","tags_url":"https://api.github.com/repos/boost-experimental/di/tags","blobs_url":"https://api.github.com/repos/boost-experimental/di/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/boost-experimental/di/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/boost-experimental/di/git/refs{/sha}","trees_url":"https://api.github.com/repos/boost-experimental/di/git/trees{/sha}","statuses_url":"https://api.github.com/repos/boost-experimental/di/statuses/{sha}","languages_url":"https://api.github.com/repos/boost-experimental/di/languages","stargazers_url":"https://api.github.com/repos/boost-experimental/di/stargazers","contributors_url":"https://api.github.com/repos/boost-experimental/di/contributors","subscribers_url":"https://api.github.com/repos/boost-experimental/di/subscribers","subscription_url":"https://api.github.com/repos/boost-experimental/di/subscription","commits_url":"https://api.github.com/repos/boost-experimental/di/commits{/sha}","git_commits_url":"https://api.github.com/repos/boost-experimental/di/git/commits{/sha}","comments_url":"https://api.github.com/repos/boost-experimental/di/comments{/number}","issue_comment_url":"https://api.github.com/repos/boost-experimental/di/issues/comments{/number}","contents_url":"https://api.github.com/repos/boost-experimental/di/contents/{+path}","compare_url":"https://api.github.com/repos/boost-experimental/di/compare/{base}...{head}","merges_url":"https://api.github.com/repos/boost-experimental/di/merges","archive_url":"https://api.github.com/repos/boost-experimental/di/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/boost-experimental/di/downloads","issues_url":"https://api.github.com/repos/boost-experimental/di/issues{/number}","pulls_url":"https://api.github.com/repos/boost-experimental/di/pulls{/number}","milestones_url":"https://api.github.com/repos/boost-experimental/di/milestones{/number}","notifications_url":"https://api.github.com/repos/boost-experimental/di/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/boost-experimental/di/labels{/name}","releases_url":"https://api.github.com/repos/boost-experimental/di/releases{/id}","deployments_url":"https://api.github.com/repos/boost-experimental/di/deployments","created_at":"2012-01-23T21:42:55Z","updated_at":"2018-12-30T03:20:25Z","pushed_at":"2018-12-31T06:34:00Z","git_url":"git://github.com/boost-experimental/di.git","ssh_url":"git@github.com:boost-experimental/di.git","clone_url":"https://github.com/boost-experimental/di.git","svn_url":"https://github.com/boost-experimental/di","homepage":"http://boost-experimental.github.io/di","size":51580,"stargazers_count":493,"watchers_count":493,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":44,"mirror_url":null,"archived":false,"open_issues_count":14,"license":null,"forks":44,"open_issues":14,"watchers":493,"default_branch":"cpp14"}},"base":{"label":"boost-experimental:cpp14","ref":"cpp14","sha":"0c28af354a38220ea2f631b4ca12a7325411daef","user":{"login":"boost-experimental","id":16814575,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2ODE0NTc1","avatar_url":"https://avatars2.githubusercontent.com/u/16814575?v=4","gravatar_id":"","url":"https://api.github.com/users/boost-experimental","html_url":"https://github.com/boost-experimental","followers_url":"https://api.github.com/users/boost-experimental/followers","following_url":"https://api.github.com/users/boost-experimental/following{/other_user}","gists_url":"https://api.github.com/users/boost-experimental/gists{/gist_id}","starred_url":"https://api.github.com/users/boost-experimental/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boost-experimental/subscriptions","organizations_url":"https://api.github.com/users/boost-experimental/orgs","repos_url":"https://api.github.com/users/boost-experimental/repos","events_url":"https://api.github.com/users/boost-experimental/events{/privacy}","received_events_url":"https://api.github.com/users/boost-experimental/received_events","type":"Organization","site_admin":false},"repo":{"id":3250728,"node_id":"MDEwOlJlcG9zaXRvcnkzMjUwNzI4","name":"di","full_name":"boost-experimental/di","private":false,"owner":{"login":"boost-experimental","id":16814575,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2ODE0NTc1","avatar_url":"https://avatars2.githubusercontent.com/u/16814575?v=4","gravatar_id":"","url":"https://api.github.com/users/boost-experimental","html_url":"https://github.com/boost-experimental","followers_url":"https://api.github.com/users/boost-experimental/followers","following_url":"https://api.github.com/users/boost-experimental/following{/other_user}","gists_url":"https://api.github.com/users/boost-experimental/gists{/gist_id}","starred_url":"https://api.github.com/users/boost-experimental/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boost-experimental/subscriptions","organizations_url":"https://api.github.com/users/boost-experimental/orgs","repos_url":"https://api.github.com/users/boost-experimental/repos","events_url":"https://api.github.com/users/boost-experimental/events{/privacy}","received_events_url":"https://api.github.com/users/boost-experimental/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/boost-experimental/di","description":"[Boost].DI: C++14 Dependency Injection Library","fork":false,"url":"https://api.github.com/repos/boost-experimental/di","forks_url":"https://api.github.com/repos/boost-experimental/di/forks","keys_url":"https://api.github.com/repos/boost-experimental/di/keys{/key_id}","collaborators_url":"https://api.github.com/repos/boost-experimental/di/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/boost-experimental/di/teams","hooks_url":"https://api.github.com/repos/boost-experimental/di/hooks","issue_events_url":"https://api.github.com/repos/boost-experimental/di/issues/events{/number}","events_url":"https://api.github.com/repos/boost-experimental/di/events","assignees_url":"https://api.github.com/repos/boost-experimental/di/assignees{/user}","branches_url":"https://api.github.com/repos/boost-experimental/di/branches{/branch}","tags_url":"https://api.github.com/repos/boost-experimental/di/tags","blobs_url":"https://api.github.com/repos/boost-experimental/di/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/boost-experimental/di/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/boost-experimental/di/git/refs{/sha}","trees_url":"https://api.github.com/repos/boost-experimental/di/git/trees{/sha}","statuses_url":"https://api.github.com/repos/boost-experimental/di/statuses/{sha}","languages_url":"https://api.github.com/repos/boost-experimental/di/languages","stargazers_url":"https://api.github.com/repos/boost-experimental/di/stargazers","contributors_url":"https://api.github.com/repos/boost-experimental/di/contributors","subscribers_url":"https://api.github.com/repos/boost-experimental/di/subscribers","subscription_url":"https://api.github.com/repos/boost-experimental/di/subscription","commits_url":"https://api.github.com/repos/boost-experimental/di/commits{/sha}","git_commits_url":"https://api.github.com/repos/boost-experimental/di/git/commits{/sha}","comments_url":"https://api.github.com/repos/boost-experimental/di/comments{/number}","issue_comment_url":"https://api.github.com/repos/boost-experimental/di/issues/comments{/number}","contents_url":"https://api.github.com/repos/boost-experimental/di/contents/{+path}","compare_url":"https://api.github.com/repos/boost-experimental/di/compare/{base}...{head}","merges_url":"https://api.github.com/repos/boost-experimental/di/merges","archive_url":"https://api.github.com/repos/boost-experimental/di/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/boost-experimental/di/downloads","issues_url":"https://api.github.com/repos/boost-experimental/di/issues{/number}","pulls_url":"https://api.github.com/repos/boost-experimental/di/pulls{/number}","milestones_url":"https://api.github.com/repos/boost-experimental/di/milestones{/number}","notifications_url":"https://api.github.com/repos/boost-experimental/di/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/boost-experimental/di/labels{/name}","releases_url":"https://api.github.com/repos/boost-experimental/di/releases{/id}","deployments_url":"https://api.github.com/repos/boost-experimental/di/deployments","created_at":"2012-01-23T21:42:55Z","updated_at":"2018-12-30T03:20:25Z","pushed_at":"2018-12-31T06:34:00Z","git_url":"git://github.com/boost-experimental/di.git","ssh_url":"git@github.com:boost-experimental/di.git","clone_url":"https://github.com/boost-experimental/di.git","svn_url":"https://github.com/boost-experimental/di","homepage":"http://boost-experimental.github.io/di","size":51580,"stargazers_count":493,"watchers_count":493,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":44,"mirror_url":null,"archived":false,"open_issues_count":14,"license":null,"forks":44,"open_issues":14,"watchers":493,"default_branch":"cpp14"}},"_links":{"self":{"href":"https://api.github.com/repos/boost-experimental/di/pulls/372"},"html":{"href":"https://github.com/boost-experimental/di/pull/372"},"issue":{"href":"https://api.github.com/repos/boost-experimental/di/issues/372"},"comments":{"href":"https://api.github.com/repos/boost-experimental/di/issues/372/comments"},"review_comments":{"href":"https://api.github.com/repos/boost-experimental/di/pulls/372/comments"},"review_comment":{"href":"https://api.github.com/repos/boost-experimental/di/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/boost-experimental/di/pulls/372/commits"},"statuses":{"href":"https://api.github.com/repos/boost-experimental/di/statuses/b53af79d0527a104e14526c991af04a69ad522bd"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"kanstantsin-chernik"}}