{"id":346875,"date":"2023-03-16T21:01:11","date_gmt":"2023-03-16T21:01:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=346875"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2023-03-16T21:01:11","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=346875","title":{"rendered":"<span>\u0427\u0442\u043e \u0432 DI-\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0442\u0432\u043e\u0435\u043c, \u0421++? \u041f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0436\u0438\u0442\u0435\u043b\u0438 \u0425\u0430\u0431\u0440\u0430. <\/p>\n<p>\u0418\u0437-\u0437\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 C# \u043c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0445 DI-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u043d\u0430 C++. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u043e\u0431\u044b\u0432\u0430\u043b \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043b\u044e\u0441\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u0433\u0434\u0435 \u0431\u044b\u043b\u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0438, \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u044b \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0448\u0442\u0443\u043a\u0438. \u0418 \u044f \u043d\u0430\u0447\u0430\u043b \u0438\u0441\u043a\u0430\u0442\u044c, \u0445\u043e\u0442\u044f \u043e\u0436\u0438\u0434\u0430\u043b, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u043e\u0433\u043e \u044f \u043d\u0435 \u043d\u0430\u0439\u0434\u0443.<\/p>\n<p>\u0418 \u0431\u044b\u043b \u043f\u0440\u0430\u0432, \u0442\u0430\u043a \u043a\u0430\u043a \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e \u0432 C++ \u0435\u0449\u0451 \u043d\u0435 \u0437\u0430\u0432\u0435\u0437\u043b\u0438. \u0425\u043e\u0442\u044f \u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/keyword\/reflexpr\" rel=\"noopener noreferrer nofollow\">reflection ts<\/a> \u0438 \u0434\u0430\u0436\u0435 \u0431\u044b\u043b\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/598981\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u044f<\/a> \u043d\u0430 \u0445\u0430\u0431\u0440\u0435, \u043d\u043e \u043f\u043e\u043a\u0430 \u0447\u0430\u0441\u0442\u044c\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 \u044d\u0442\u043e \u043d\u0435 \u0441\u0442\u0430\u043b\u043e. \u042f \u0431\u044b \u0436\u0435\u043b\u0430\u043b, \u0447\u0442\u043e\u0431\u044b \u0435\u0449\u0451 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0440\u043e\u0441\u043b\u0430 \u0431\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0439, \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u043e\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438. \u041d\u043e \u044d\u0442\u043e \u0432\u0441\u0451 \u043c\u0435\u0447\u0442\u044b.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0447\u0442\u043e \u0436\u0435 \u0431\u044b\u043b\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043e? <\/p>\n<p>\u0424\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/boost-ext\/di\" rel=\"noopener noreferrer nofollow\">Boost.DI<\/a> (<a href=\"https:\/\/habr.com\/ru\/company\/infopulse\/blog\/248879\/\" rel=\"noopener noreferrer nofollow\">\u0445\u0430\u0431\u0440<\/a>) <\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/google\/fruit\" rel=\"noopener noreferrer nofollow\">Google Fruit<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/ybainier\/Hypodermic\" rel=\"noopener noreferrer nofollow\">Hypodermic<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/gracicot\/kangaru\" rel=\"noopener noreferrer nofollow\">Kangaru<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/wallaroolib.sourceforge.net\/\" rel=\"noopener noreferrer nofollow\">Wallaroo<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u0438 \u0432\u0438\u0434\u0435\u043e\u0440\u043e\u043b\u0438\u043a\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/222007\/\" rel=\"noopener noreferrer nofollow\">\u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 \u0421++<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/devsday.ru\/blog\/details\/1581\" rel=\"noopener noreferrer nofollow\">\u041e\u0431\u0437\u043e\u0440 \u0421++ \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0434\u043b\u044f \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439: kangaru \u0438 [Boost].DI<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=UhSgMNf_E7w\" rel=\"noopener noreferrer nofollow\">\u0417\u0430\u043f\u0438\u0441\u044c \u0434\u043e\u043a\u043b\u0430\u0434\u0430 \u043e\u0442 \u0410\u043d\u0442\u043e\u043d\u0430 \u0429\u0435\u0440\u0431\u0430\u043a\u043e\u0432\u0430 \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0439<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.fluentcpp.com\/2019\/06\/07\/write-your-own-dependency-injection-container\/\" rel=\"noopener noreferrer nofollow\">Write Your Own Dependency Injection Container<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.codeproject.com\/Articles\/1029836\/A-Miniature-IOC-Container-in-Cplusplus\" rel=\"noopener noreferrer nofollow\">A Miniature IOC Container in C++<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u0438\u043c\u0435\u044e\u0442 \u0442\u0435 \u0438\u043b\u0438 \u0438\u043d\u044b\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438. <em>Fruit,<\/em> \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0430\u0435\u043c\u043e\u0433\u043e \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0438. <em>Wallaroo<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043d\u0430 \u043f\u043e\u043b\u044f\u0445 \u043a\u043b\u0430\u0441\u0441\u0430. <em>Kangaru<\/em> \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0447\u0435\u043c \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. <em>Hypodermic<\/em> \u0443\u0436\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u0441\u043d\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0438 \u043a\u043e\u0434 \u043d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0438 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439. <em>Boost.DI<\/em>&#8230; \u043d\u0443&#8230; \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/boost-ext\/di\/blob\/cpp14\/include\/boost\/di.hpp\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a<\/a>&#8230;<\/p>\n<p>\u0412\u0441\u0451 \u044d\u0442\u043e \u0434\u043b\u044f \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u043e, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0441\u0432\u043e\u0435\u0433\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e, \u043f\u043e-\u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043d\u043e\u043c\u0443 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0433\u043e&#8230; \u0438 \u0432\u043e\u0442 \u044f \u043d\u0430\u0447\u0430\u043b \u043f\u0438\u0441\u0430\u0442\u044c.<\/p>\n<h2>\u041f\u0435\u0440\u0435\u0434 \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u043f\u0443\u0442\u0438<\/h2>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u044f \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u0437\u0430\u0434\u0430\u0432\u0430\u043b\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c: &#171;\u0410 \u0447\u0435\u0433\u043e \u044f \u0445\u043e\u0447\u0443 \u043e\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430?&#187;. \u0418 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0432\u044b\u0432\u0435\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439:<\/p>\n<ul>\n<li>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u044a\u0451\u043c \u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u043a\u043b\u0430\u0441\u0441\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432. \u041d\u0435 \u0442\u043e \u0447\u0442\u043e\u0431\u044b \u044f \u0438\u0445 \u043d\u0435 \u043b\u044e\u0431\u043b\u044e. \u0423 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043a\u043e\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u044f, \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043d\u0435 \u0445\u043e\u0442\u0435\u043b \u0431\u044b, \u0447\u0442\u043e\u0431\u044b \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u044f\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0438\u043b\u0430 \u043c\u043d\u0435 \u0432 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 IDE. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043b\u044e\u0431\u043e\u0432\u044c C++ \u0432\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u0434\u0442\u044f\u043d\u0443\u0442 \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u043f\u043e \u0442\u0438\u043f\u0443 Rust&#8217;\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0443\u043c\u043d\u044b\u0435 \u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438, \u0438 \u0441\u0441\u044b\u043b\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 <u>\u043d\u0435<\/u> \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043b\u044e\u0431\u044b\u0435 \u0442\u0438\u043f\u044b, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438, \u043d\u043e \u044d\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<h2>\u041e\u0441\u043d\u043e\u0432\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430<\/h2>\n<p>\u041e\u0441\u043d\u043e\u0432\u043e\u0439 DI \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0432 \u0421++ \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 <s>\u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044f<\/s> \u0448\u0430\u0431\u043b\u043e\u043d\u044b. Hypodermic \u0443\u043c\u0443\u0434\u0440\u044f\u0435\u0442\u0441\u044f \u0441 \u0438\u0445 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u0438\u043f\u044b \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432 \u043c\u0438\u0440\u0435 \u0421++ \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u0440\u043e\u0434\u0435 moc \u043e\u0442 Qt \u0438\u043b\u0438 UnrealHeaderTool \u043e\u0442 UnrealEngine. \u041f\u0440\u043e\u0441\u0442\u043e \u0432\u0441\u0451 \u044d\u0442\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u0438 \u043b\u044e\u0434\u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0445\u043e\u0442\u044f\u0442 \u043e\u0442 \u043d\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c. <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0438\u043f\u044b \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430. \u0410 \u0432 \u0447\u0451\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0435\u0441\u043b\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438 \u0432 \u043f\u043b\u044e\u0441\u0430\u0445? \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439. \u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0435\u0441\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0451 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0442\u043e \u0441 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442.<\/p>\n<p>Hypodermic \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. <a href=\"https:\/\/github.com\/ybainier\/Hypodermic\/blob\/master\/Hypodermic\/ConstructorDescriptor.h#L36\" rel=\"noopener noreferrer nofollow\">\u041a\u043e\u0434 <\/a>\u043d\u0438\u0436\u0435 \u0438\u0437 \u0441\u0430\u043c\u043e\u0433\u043e Hypodermic<\/p>\n<pre><code class=\"cpp\">struct ArgumentResolverInvoker {    template &lt;class T, class = \/*scary code*\/>   operator T()   {       return ArgumentResolver&lt; typename std::decay&lt; T >::type >::template resolve(m_registration, m_resolutionContext);   } }<\/code><\/pre>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0442\u0438\u043f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0434\u043b\u044f ArgumentResolverInvoker \u0438 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u0442\u0438\u043f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u0438 \u0442\u0430\u043c \u043f\u043e\u0437\u0430\u0434\u0438 \u0435\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u044d\u0442\u043e\u043c \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442.<\/p>\n<p>\u042f \u0436\u0435 \u0432\u044b\u0431\u0440\u0430\u043b \u043f\u0443\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430. \u0414\u0430 \u0432 \u043e\u0431\u0449\u0435\u043c \u0442\u043e \u043e\u043d\u043e \u0438 \u043d\u0435\u043f\u043b\u043e\u0445\u043e. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u044f \u043f\u043e\u0434\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 <abbr class=\"habraabbr\" title=\"Game Engine Gems3 (Lengyel, 2003) page 194\" data-title=\"&lt;p>Game Engine Gems3 (Lengyel, 2003) page 194&lt;\/p>&#187; data-abbr=&#187;\u043a\u043d\u0438\u0433&#187;>\u043a\u043d\u0438\u0433<\/abbr>, \u0442\u0430\u043c \u0431\u044b\u043b \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u044b\u0441\u0442\u0440\u044b\u0445 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u0432 \u043d\u0430 \u043f\u043b\u044e\u0441\u0430\u0445. <\/p>\n<pre><code class=\"coffeescript\">template&lt;class FunctionType> struct Factory;  template&lt;class Type, class ... Args> struct Factory&lt;Type(Args...)> {   static void* Create(Container* container)   {     return TypeTraits&lt;Type>::Create(container->resolve&lt;Args>()...);   } }<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u0442\u0430\u0440\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u0443\u0437\u043a\u043e\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u0438 \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c<br \/>Factory&lt;decltype(TypeTraits&lt;Foo>::Create)><br \/>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u043a\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u0434\u043b\u044f \u043d\u0430\u0441 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0442\u0438\u043f\u044b.<\/p>\n<p>TypeTraits \u044d\u0442\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0438\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 Create, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430. <br \/>\u041a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Type \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043e\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>\u041d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043c\u0435\u0442\u043e\u0434 Create \u043d\u0435\u043c\u043d\u043e\u0433\u043e&#8230; \u0433\u0440\u0443\u0441\u0442\u043d\u043e. \u041d\u043e \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u043e\u043f\u044f\u0442\u044c \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043a\u0440\u0443\u0442\u0438\u0442\u044c\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c<\/p>\n<pre><code class=\"cpp\">template&lt;class T, class... Args> struct Constructor {   T* Create(Args... args)   {     return new T(std::forward&lt;Args>(args)...);   } };   template&lt;> struct TypeTraits&lt;Foo> : Constructor&lt;Foo, Dependency1...> {   \/\/ TypeTraits \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f Create \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442   constexpr LifeTimeScope LifeTime = LifeTimeScope::Singleton;   \/\/ ... };<\/code><\/pre>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 Create \u0432 TypeTraits \u0438 \u0441\u0430\u043c TypeTraits \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430 \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0432\u0435\u0449\u0435\u0439:<\/p>\n<ol>\n<li>\n<p>\u041a\u043b\u0430\u0441\u0441\u044b \u0438\u0437 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u0445, \u043e\u043f\u0438\u0441\u0430\u0432 TypeTraits.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u044b \u0432 Create<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0437\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e\u0441\u0442-\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. <\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u044f \u0434\u043e\u0433\u0430\u0434\u044b\u0432\u0430\u044e\u0441\u044c, \u0447\u0442\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0435 DI \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435. <\/p>\n<h2>\u041d\u0430\u0445\u043e\u0434\u0438\u043c Id \u0434\u043b\u044f \u0442\u0438\u043f\u0430<\/h2>\n<p>\u0425\u043e\u0440\u043e\u0448\u043e, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0444\u0430\u0431\u0440\u0438\u043a\u0438. \u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043d\u0443\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0430\u0434\u0440\u0435\u0441 Factory::Create \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0435\u0433\u043e \u0432 map. \u0417\u0430\u0442\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043d\u0430\u043c \u0442\u0438\u043f\u0430, \u043c\u044b \u0434\u043e\u0441\u0442\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0438\u0437 \u043c\u0430\u043f\u044b \u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442. \u0410 \u043a\u0430\u043a \u043c\u044b \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u043c? \u0412\u0435\u0434\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 Resolve \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0430 map \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: \u043e\u0434\u043d\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u043d\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0435\u0449\u0451 \u043e\u0434\u043d\u0438\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434\u043e\u043c. <\/p>\n<pre><code class=\"cpp\">template&lt;class T> size_t GetTypeId() {   return reintepret_cast&lt;size_t>(&amp;GetTypeId); }<\/code><\/pre>\n<p>\u0414\u0430, \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u0430\u043a \u043a\u043b\u044e\u0447\u043e\u043c \u0432 map. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u0432\u043e\u0451 \u043c\u0435\u0441\u0442\u043e \u043f\u0430\u043c\u044f\u0442\u0438, \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c id. \u041c\u043d\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u0448\u043b\u0430 \u0438\u0434\u0435\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u043c\u0435\u0442\u043e\u0434\u0430 Create \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u0438, \u043d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u0442\u0438\u043f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u043c\u0435\u0442\u043e\u0434\u0430 Create \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0443 \u043d\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u0431\u044b\u0442\u044c. <\/p>\n<h2>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0436\u0438\u0437\u043d\u0438 \u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439<\/h2>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0435\u0441\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u0434 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u0442\u0435\u0445\u043d\u0438\u043a\u0438. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u044d\u0442\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0436\u0438\u0437\u043d\u0438. <br \/>\u042f \u0432\u044b\u0434\u0435\u043b\u0438\u043b 3 \u0442\u0438\u043f\u0430: <\/p>\n<ol>\n<li>\n<p>\u0421\u0438\u043d\u0433\u043b\u0442\u043e\u043d &#8212; \u0436\u0438\u0432\u0435\u0442 \u0432\u0441\u0451 \u0432\u0440\u0435\u043c\u044f, \u043f\u043e\u043a\u0430 \u0436\u0438\u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u044b. <\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u0441\u0441\u044b\u043b\u043e\u043a &#8212; \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442, \u043f\u043e\u043a\u0430 \u0436\u0438\u0432\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435\u0441\u044f \u044d\u0442\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>\u041d\u0438\u043a\u0430\u043a &#8212; \u043a\u043b\u0438\u0435\u043d\u0442 \u0441\u0430\u043c \u0440\u0435\u0448\u0430\u0435\u0442, \u0447\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u0434\u0435\u043b\u0430\u0442\u044c. <\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 2 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0442\u0435\u043c, \u043a\u0430\u043a\u043e\u0439 \u0443\u043c\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435: shared_ptr \u0438\u043b\u0438 weak_ptr, \u0438 \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0443. \u041f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443, \u0438\u043c\u0435\u044f weak_ptr \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c.<\/p>\n<p>\u0418 \u043a\u0430\u043a \u0436\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435? \u0414\u043b\u044f \u044d\u0442\u043e \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c std::variant. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0441\u0432\u0435\u0441\u0442\u0438 \u0432\u0441\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0432 \u043e\u0434\u0438\u043d. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e shared_ptr&lt;void> \u0438 \u0442.\u043f. \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0443\u0440\u043d\u043e\u0439 \u0442\u043e\u043d \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u043c\u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u0439 \u043d\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 Resolve, \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f. <\/p>\n<h2>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a \u0442\u0438\u043f\u0443, \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u043c\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c<\/h2>\n<p> \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 Resolve \u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0438\u043f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430<\/p>\n<pre><code class=\"cpp\">static void* Create(Container* container) {   return TypeTraits&lt;Type>::Create(container->resolve&lt;Args>()...); }<\/code><\/pre>\n<p>\u0418, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0442\u0438\u043f\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c shared_ptr&lt;Dependency> \u0438\u043b\u0438 Dependency&amp;, \u043d\u043e \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d Dependency, \u0430 \u043d\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c: &#171;\u0411\u043e\u043b\u044c\u0448\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0431\u043e\u0433\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432&#187; \u0438 \u0438\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<pre><code class=\"cpp\">template&lt;class T, class ... Args> using Reference = T&amp;;  template&lt;class T, class ... Args> using SharedPtr = std::shared_ptr&lt;T>;  template&lt;class T> struct WrapperInfo { };  template&lt;class T> struct WrapperInfo&lt;T&amp;> {     using Type = T;      template&lt;class P, class ... PArgs>     using Wrapper = Reference&lt;P>; };  template&lt;class T, template &lt;class P, class ... PArgs> class TWrapper, class ... TArgs> struct WrapperInfo&lt;TWrapper&lt;T, TArgs...>> {     using Type = T;      template&lt;class P, class ... PArgs>     using Wrapper = TWrapper&lt;P>; };<\/code><\/pre>\n<p>\u0421\u043d\u043e\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u0443\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0434\u043b\u044f \u0432\u044b\u044f\u0441\u043d\u0435\u043d\u0438\u044f, \u043a\u0430\u043a\u043e\u0439 \u0436\u0435 \u0442\u0438\u043f \u0443 \u043d\u0430\u0441 \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0435. \u0418 \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 Create \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u043e\u0434\u043e\u043c<\/p>\n<pre><code class=\"cpp\">static void* Create(Container* container) {   return TypeTraits&lt;Type>::Create(     container->resolve&lt;typename WrapperInfo&lt;Args>::Type, WrapperInfo&lt;Args>::template Wrapper>()...   ); }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u0435\u0442\u043e\u0434 Resolve \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u0438 \u0432 \u043a\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435 \u0435\u043c\u0443 \u043d\u0430\u0434\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c. <\/p>\n<h2>\u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u0441\u0435\u0433\u043e \u043e\u043a\u043e\u043b\u043e 500 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430, \u0438 \u0432 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. \u041a\u043e\u0434 \u0441\u0432\u043e\u0435\u0433\u043e \u043c\u0438\u043d\u0438 DI \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u044f \u0432\u044b\u043b\u043e\u0436\u0438\u043b \u043d\u0430 <a href=\"https:\/\/github.com\/Dartjek\/SDIL\" rel=\"noopener noreferrer nofollow\">\u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a>.  \u041f\u0443\u0441\u0442\u044c \u044d\u0442\u043e \u0438 \u043d\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0441\u044f \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u043c\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u043c\u0438, \u043d\u043e \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e\u0439 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u043c\u043e\u0438\u0445 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430\u0445 \u0445\u0432\u0430\u0442\u0438\u0442.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/722940\/\"> https:\/\/habr.com\/ru\/post\/722940\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0436\u0438\u0442\u0435\u043b\u0438 \u0425\u0430\u0431\u0440\u0430. <\/p>\n<p>\u0418\u0437-\u0437\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 C# \u043c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0445 DI-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u043d\u0430 C++. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u043e\u0431\u044b\u0432\u0430\u043b \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043b\u044e\u0441\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u0433\u0434\u0435 \u0431\u044b\u043b\u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0438, \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u044b \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0448\u0442\u0443\u043a\u0438. \u0418 \u044f \u043d\u0430\u0447\u0430\u043b \u0438\u0441\u043a\u0430\u0442\u044c, \u0445\u043e\u0442\u044f \u043e\u0436\u0438\u0434\u0430\u043b, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u043e\u0433\u043e \u044f \u043d\u0435 \u043d\u0430\u0439\u0434\u0443.<\/p>\n<p>\u0418 \u0431\u044b\u043b \u043f\u0440\u0430\u0432, \u0442\u0430\u043a \u043a\u0430\u043a \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e \u0432 C++ \u0435\u0449\u0451 \u043d\u0435 \u0437\u0430\u0432\u0435\u0437\u043b\u0438. \u0425\u043e\u0442\u044f \u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/keyword\/reflexpr\" rel=\"noopener noreferrer nofollow\">reflection ts<\/a> \u0438 \u0434\u0430\u0436\u0435 \u0431\u044b\u043b\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/598981\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u044f<\/a> \u043d\u0430 \u0445\u0430\u0431\u0440\u0435, \u043d\u043e \u043f\u043e\u043a\u0430 \u0447\u0430\u0441\u0442\u044c\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 \u044d\u0442\u043e \u043d\u0435 \u0441\u0442\u0430\u043b\u043e. \u042f \u0431\u044b \u0436\u0435\u043b\u0430\u043b, \u0447\u0442\u043e\u0431\u044b \u0435\u0449\u0451 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0440\u043e\u0441\u043b\u0430 \u0431\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0439, \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u043e\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438. \u041d\u043e \u044d\u0442\u043e \u0432\u0441\u0451 \u043c\u0435\u0447\u0442\u044b.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0447\u0442\u043e \u0436\u0435 \u0431\u044b\u043b\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043e? <\/p>\n<p>\u0424\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/boost-ext\/di\" rel=\"noopener noreferrer nofollow\">Boost.DI<\/a> (<a href=\"https:\/\/habr.com\/ru\/company\/infopulse\/blog\/248879\/\" rel=\"noopener noreferrer nofollow\">\u0445\u0430\u0431\u0440<\/a>) <\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/google\/fruit\" rel=\"noopener noreferrer nofollow\">Google Fruit<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/ybainier\/Hypodermic\" rel=\"noopener noreferrer nofollow\">Hypodermic<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/gracicot\/kangaru\" rel=\"noopener noreferrer nofollow\">Kangaru<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/wallaroolib.sourceforge.net\/\" rel=\"noopener noreferrer nofollow\">Wallaroo<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u0438 \u0432\u0438\u0434\u0435\u043e\u0440\u043e\u043b\u0438\u043a\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/222007\/\" rel=\"noopener noreferrer nofollow\">\u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 \u0421++<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/devsday.ru\/blog\/details\/1581\" rel=\"noopener noreferrer nofollow\">\u041e\u0431\u0437\u043e\u0440 \u0421++ \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0434\u043b\u044f \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439: kangaru \u0438 [Boost].DI<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=UhSgMNf_E7w\" rel=\"noopener noreferrer nofollow\">\u0417\u0430\u043f\u0438\u0441\u044c \u0434\u043e\u043a\u043b\u0430\u0434\u0430 \u043e\u0442 \u0410\u043d\u0442\u043e\u043d\u0430 \u0429\u0435\u0440\u0431\u0430\u043a\u043e\u0432\u0430 \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0439<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.fluentcpp.com\/2019\/06\/07\/write-your-own-dependency-injection-container\/\" rel=\"noopener noreferrer nofollow\">Write Your Own Dependency Injection Container<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.codeproject.com\/Articles\/1029836\/A-Miniature-IOC-Container-in-Cplusplus\" rel=\"noopener noreferrer nofollow\">A Miniature IOC Container in C++<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u0438\u043c\u0435\u044e\u0442 \u0442\u0435 \u0438\u043b\u0438 \u0438\u043d\u044b\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438. <em>Fruit,<\/em> \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0430\u0435\u043c\u043e\u0433\u043e \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0438. <em>Wallaroo<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043d\u0430 \u043f\u043e\u043b\u044f\u0445 \u043a\u043b\u0430\u0441\u0441\u0430. <em>Kangaru<\/em> \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0447\u0435\u043c \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. <em>Hypodermic<\/em> \u0443\u0436\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u0441\u043d\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0438 \u043a\u043e\u0434 \u043d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0438 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439. <em>Boost.DI<\/em>&#8230; \u043d\u0443&#8230; \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/boost-ext\/di\/blob\/cpp14\/include\/boost\/di.hpp\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a<\/a>&#8230;<\/p>\n<p>\u0412\u0441\u0451 \u044d\u0442\u043e \u0434\u043b\u044f \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u043e, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0441\u0432\u043e\u0435\u0433\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e, \u043f\u043e-\u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043d\u043e\u043c\u0443 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0433\u043e&#8230; \u0438 \u0432\u043e\u0442 \u044f \u043d\u0430\u0447\u0430\u043b \u043f\u0438\u0441\u0430\u0442\u044c.<\/p>\n<h2>\u041f\u0435\u0440\u0435\u0434 \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u043f\u0443\u0442\u0438<\/h2>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u044f \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u0437\u0430\u0434\u0430\u0432\u0430\u043b\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c: &#171;\u0410 \u0447\u0435\u0433\u043e \u044f \u0445\u043e\u0447\u0443 \u043e\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430?&#187;. \u0418 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0432\u044b\u0432\u0435\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439:<\/p>\n<ul>\n<li>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u044a\u0451\u043c \u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u043a\u043b\u0430\u0441\u0441\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432. \u041d\u0435 \u0442\u043e \u0447\u0442\u043e\u0431\u044b \u044f \u0438\u0445 \u043d\u0435 \u043b\u044e\u0431\u043b\u044e. \u0423 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043a\u043e\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u044f, \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043d\u0435 \u0445\u043e\u0442\u0435\u043b \u0431\u044b, \u0447\u0442\u043e\u0431\u044b \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u044f\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0438\u043b\u0430 \u043c\u043d\u0435 \u0432 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 IDE. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043b\u044e\u0431\u043e\u0432\u044c C++ \u0432\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u0434\u0442\u044f\u043d\u0443\u0442 \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u043f\u043e \u0442\u0438\u043f\u0443 Rust&#8217;\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0443\u043c\u043d\u044b\u0435 \u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438, \u0438 \u0441\u0441\u044b\u043b\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 <u>\u043d\u0435<\/u> \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043b\u044e\u0431\u044b\u0435 \u0442\u0438\u043f\u044b, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438, \u043d\u043e \u044d\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<h2>\u041e\u0441\u043d\u043e\u0432\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430<\/h2>\n<p>\u041e\u0441\u043d\u043e\u0432\u043e\u0439 DI \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0432 \u0421++ \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 <s>\u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044f<\/s> \u0448\u0430\u0431\u043b\u043e\u043d\u044b. Hypodermic \u0443\u043c\u0443\u0434\u0440\u044f\u0435\u0442\u0441\u044f \u0441 \u0438\u0445 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u0438\u043f\u044b \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432 \u043c\u0438\u0440\u0435 \u0421++ \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u0440\u043e\u0434\u0435 moc \u043e\u0442 Qt \u0438\u043b\u0438 UnrealHeaderTool \u043e\u0442 UnrealEngine. \u041f\u0440\u043e\u0441\u0442\u043e \u0432\u0441\u0451 \u044d\u0442\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u0438 \u043b\u044e\u0434\u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0445\u043e\u0442\u044f\u0442 \u043e\u0442 \u043d\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c. <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0438\u043f\u044b \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430. \u0410 \u0432 \u0447\u0451\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0435\u0441\u043b\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438 \u0432 \u043f\u043b\u044e\u0441\u0430\u0445? \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439. \u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0435\u0441\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0451 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0442\u043e \u0441 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442.<\/p>\n<p>Hypodermic \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. <a href=\"https:\/\/github.com\/ybainier\/Hypodermic\/blob\/master\/Hypodermic\/ConstructorDescriptor.h#L36\" rel=\"noopener noreferrer nofollow\">\u041a\u043e\u0434 <\/a>\u043d\u0438\u0436\u0435 \u0438\u0437 \u0441\u0430\u043c\u043e\u0433\u043e Hypodermic<\/p>\n<pre><code class=\"cpp\">struct ArgumentResolverInvoker {    template &lt;class T, class = \/*scary code*\/>   operator T()   {       return ArgumentResolver&lt; typename std::decay&lt; T >::type >::template resolve(m_registration, m_resolutionContext);   } }<\/code><\/pre>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0442\u0438\u043f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0434\u043b\u044f ArgumentResolverInvoker \u0438 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u0442\u0438\u043f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u0438 \u0442\u0430\u043c \u043f\u043e\u0437\u0430\u0434\u0438 \u0435\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u044d\u0442\u043e\u043c \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442.<\/p>\n<p>\u042f \u0436\u0435 \u0432\u044b\u0431\u0440\u0430\u043b \u043f\u0443\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430. \u0414\u0430 \u0432 \u043e\u0431\u0449\u0435\u043c \u0442\u043e \u043e\u043d\u043e \u0438 \u043d\u0435\u043f\u043b\u043e\u0445\u043e. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u044f \u043f\u043e\u0434\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 <abbr class=\"habraabbr\" title=\"Game Engine Gems3 (Lengyel, 2003) page 194\" data-title=\"&lt;p>Game Engine Gems3 (Lengyel, 2003) page 194&lt;\/p>&#187; data-abbr=&#187;\u043a\u043d\u0438\u0433&#187;>\u043a\u043d\u0438\u0433<\/abbr>, \u0442\u0430\u043c \u0431\u044b\u043b \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u044b\u0441\u0442\u0440\u044b\u0445 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u0432 \u043d\u0430 \u043f\u043b\u044e\u0441\u0430\u0445. <\/p>\n<pre><code class=\"coffeescript\">template&lt;class FunctionType> struct Factory;  template&lt;class Type, class ... Args> struct Factory&lt;Type(Args...)> {   static void* Create(Container* container)   {     return TypeTraits&lt;Type>::Create(container->resolve&lt;Args>()...);   } }<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u0442\u0430\u0440\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u0443\u0437\u043a\u043e\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u0438 \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c<br \/>Factory&lt;decltype(TypeTraits&lt;Foo>::Create)><br \/>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u043a\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u0434\u043b\u044f \u043d\u0430\u0441 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0442\u0438\u043f\u044b.<\/p>\n<p>TypeTraits \u044d\u0442\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0438\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 Create, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430. <br \/>\u041a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Type \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043e\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>\u041d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043c\u0435\u0442\u043e\u0434 Create \u043d\u0435\u043c\u043d\u043e\u0433\u043e&#8230; \u0433\u0440\u0443\u0441\u0442\u043d\u043e. \u041d\u043e \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u043e\u043f\u044f\u0442\u044c \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043a\u0440\u0443\u0442\u0438\u0442\u044c\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c<\/p>\n<pre><code class=\"cpp\">template&lt;class T, class... Args> struct Constructor {   T* Create(Args... args)   {     return new T(std::forward&lt;Args>(args)...);   } };   template&lt;> struct TypeTraits&lt;Foo> : Constructor&lt;Foo, Dependency1...> {   \/\/ TypeTraits \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f Create \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442   constexpr LifeTimeScope LifeTime = LifeTimeScope::Singleton;   \/\/ ... };<\/code><\/pre>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 Create \u0432 TypeTraits \u0438 \u0441\u0430\u043c TypeTraits \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430 \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0432\u0435\u0449\u0435\u0439:<\/p>\n<ol>\n<li>\n<p>\u041a\u043b\u0430\u0441\u0441\u044b \u0438\u0437 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u0445, \u043e\u043f\u0438\u0441\u0430\u0432 TypeTraits.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u044b \u0432 Create<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0437\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e\u0441\u0442-\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. <\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u044f \u0434\u043e\u0433\u0430\u0434\u044b\u0432\u0430\u044e\u0441\u044c, \u0447\u0442\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0435 DI \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435. <\/p>\n<h2>\u041d\u0430\u0445\u043e\u0434\u0438\u043c Id \u0434\u043b\u044f \u0442\u0438\u043f\u0430<\/h2>\n<p>\u0425\u043e\u0440\u043e\u0448\u043e, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0444\u0430\u0431\u0440\u0438\u043a\u0438. \u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043d\u0443\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0430\u0434\u0440\u0435\u0441 Factory::Create \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0435\u0433\u043e \u0432 map. \u0417\u0430\u0442\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043d\u0430\u043c \u0442\u0438\u043f\u0430, \u043c\u044b \u0434\u043e\u0441\u0442\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0438\u0437 \u043c\u0430\u043f\u044b \u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442. \u0410 \u043a\u0430\u043a \u043c\u044b \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u043c? \u0412\u0435\u0434\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 Resolve \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0430 map \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: \u043e\u0434\u043d\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u043d\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0435\u0449\u0451 \u043e\u0434\u043d\u0438\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434\u043e\u043c. <\/p>\n<pre><code class=\"cpp\">template&lt;class T> size_t GetTypeId() {   return reintepret_cast&lt;size_t>(&amp;GetTypeId); }<\/code><\/pre>\n<p>\u0414\u0430, \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u0430\u043a \u043a\u043b\u044e\u0447\u043e\u043c \u0432 map. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u0432\u043e\u0451 \u043c\u0435\u0441\u0442\u043e \u043f\u0430\u043c\u044f\u0442\u0438, \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c id. \u041c\u043d\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u0448\u043b\u0430 \u0438\u0434\u0435\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u043c\u0435\u0442\u043e\u0434\u0430 Create \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u0438, \u043d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u0442\u0438\u043f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u043c\u0435\u0442\u043e\u0434\u0430 Create \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0443 \u043d\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u0431\u044b\u0442\u044c. <\/p>\n<h2>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0436\u0438\u0437\u043d\u0438 \u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439<\/h2>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0435\u0441\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u0434 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u0442\u0435\u0445\u043d\u0438\u043a\u0438. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u044d\u0442\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0436\u0438\u0437\u043d\u0438. <br \/>\u042f \u0432\u044b\u0434\u0435\u043b\u0438\u043b 3 \u0442\u0438\u043f\u0430: <\/p>\n<ol>\n<li>\n<p>\u0421\u0438\u043d\u0433\u043b\u0442\u043e\u043d &#8212; \u0436\u0438\u0432\u0435\u0442 \u0432\u0441\u0451 \u0432\u0440\u0435\u043c\u044f, \u043f\u043e\u043a\u0430 \u0436\u0438\u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u044b. <\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u0441\u0441\u044b\u043b\u043e\u043a &#8212; \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442, \u043f\u043e\u043a\u0430 \u0436\u0438\u0432\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435\u0441\u044f \u044d\u0442\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>\u041d\u0438\u043a\u0430\u043a &#8212; \u043a\u043b\u0438\u0435\u043d\u0442 \u0441\u0430\u043c \u0440\u0435\u0448\u0430\u0435\u0442, \u0447\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u0434\u0435\u043b\u0430\u0442\u044c. <\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 2 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0442\u0435\u043c, \u043a\u0430\u043a\u043e\u0439 \u0443\u043c\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435: shared_ptr \u0438\u043b\u0438 weak_ptr, \u0438 \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0443. \u041f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443, \u0438\u043c\u0435\u044f weak_ptr \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c.<\/p>\n<p>\u0418 \u043a\u0430\u043a \u0436\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435? \u0414\u043b\u044f \u044d\u0442\u043e \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c std::variant. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0441\u0432\u0435\u0441\u0442\u0438 \u0432\u0441\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0432 \u043e\u0434\u0438\u043d. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e shared_ptr&lt;void> \u0438 \u0442.\u043f. \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0443\u0440\u043d\u043e\u0439 \u0442\u043e\u043d \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u043c\u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u0439 \u043d\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 Resolve, \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f. <\/p>\n<h2>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a \u0442\u0438\u043f\u0443, \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u043c\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c<\/h2>\n<p> \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 Resolve \u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0438\u043f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430<\/p>\n<pre><code class=\"cpp\">static void* Create(Container* container) {   return TypeTraits&lt;Type>::Create(container->resolve&lt;Args>()...); }<\/code><\/pre>\n<p>\u0418, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0442\u0438\u043f\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c shared_ptr&lt;Dependency> \u0438\u043b\u0438 Dependency&amp;, \u043d\u043e \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d Dependency, \u0430 \u043d\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c: &#171;\u0411\u043e\u043b\u044c\u0448\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0431\u043e\u0433\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432&#187; \u0438 \u0438\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<pre><code class=\"cpp\">template&lt;class T, class ... Args> using Reference = T&amp;;  template&lt;class T, class ... Args> using SharedPtr = std::shared_ptr&lt;T>;  template&lt;class T> struct WrapperInfo { };  template&lt;class T> struct WrapperInfo&lt;T&amp;> {     using Type = T;      template&lt;class P, class ... PArgs>     using Wrapper = Reference&lt;P>; };  template&lt;class T, template &lt;class P, class ... PArgs> class TWrapper, class ... TArgs> struct WrapperInfo&lt;TWrapper&lt;T, TArgs...>> {     using Type = T;      template&lt;class P, class ... PArgs>     using Wrapper = TWrapper&lt;P>; };<\/code><\/pre>\n<p>\u0421\u043d\u043e\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u0443\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0434\u043b\u044f \u0432\u044b\u044f\u0441\u043d\u0435\u043d\u0438\u044f, \u043a\u0430\u043a\u043e\u0439 \u0436\u0435 \u0442\u0438\u043f \u0443 \u043d\u0430\u0441 \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0435. \u0418 \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 Create \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u043e\u0434\u043e\u043c<\/p>\n<pre><code class=\"cpp\">static void* Create(Container* container) {   return TypeTraits&lt;Type>::Create(     container->resolve&lt;typename WrapperInfo&lt;Args>::Type, WrapperInfo&lt;Args>::template Wrapper>()...   ); }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u0435\u0442\u043e\u0434 Resolve \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u0438 \u0432 \u043a\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435 \u0435\u043c\u0443 \u043d\u0430\u0434\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c. <\/p>\n<h2>\u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u0441\u0435\u0433\u043e \u043e\u043a\u043e\u043b\u043e 500 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430, \u0438 \u0432 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. \u041a\u043e\u0434 \u0441\u0432\u043e\u0435\u0433\u043e \u043c\u0438\u043d\u0438 DI \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u044f \u0432\u044b\u043b\u043e\u0436\u0438\u043b \u043d\u0430 <a href=\"https:\/\/github.com\/Dartjek\/SDIL\" rel=\"noopener noreferrer nofollow\">\u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a>.  \u041f\u0443\u0441\u0442\u044c \u044d\u0442\u043e \u0438 \u043d\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0441\u044f \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u043c\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u043c\u0438, \u043d\u043e \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e\u0439 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u043c\u043e\u0438\u0445 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430\u0445 \u0445\u0432\u0430\u0442\u0438\u0442.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/722940\/\"> https:\/\/habr.com\/ru\/post\/722940\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-346875","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346875","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=346875"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346875\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=346875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=346875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=346875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}