TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Non Intrusive Static Recursive Dependency Injection for C++14

21 pointsby matt42over 10 years ago

4 comments

cheezover 10 years ago
My favourite topic! I am glad that people are still thinking about automated DI in C++. I am sure the new standards make a lot of things easier. This library looks like a cool experiment and I hope the author continues to move in this direction.<p>Here is my version: <a href="http://bitbucket.org/cheez/dicpp" rel="nofollow">http:&#x2F;&#x2F;bitbucket.org&#x2F;cheez&#x2F;dicpp</a><p>With the following caveats:<p><pre><code> * It is not very cool * It works really well for my uses * It is not as efficient as the compile-time ones </code></pre> WRT efficiency, 99% of DI is done at application startup and you can easily make that efficient enough by delaying instantiations until you actually need them. The bottleneck at startup so far has never been the library itself.<p>I continue to look for one that allows me to create compiler firewalls so I can use <i>it</i> instead of my own.<p>Alternatively, if someone wants to give me tips to avoid the hideous DI_CONSTRUCTOR (see <a href="https://bitbucket.org/cheez/dicpp/src/HEAD/lib/examples/stockquote/StockQuoteApp.hpp#cl-15" rel="nofollow">https:&#x2F;&#x2F;bitbucket.org&#x2F;cheez&#x2F;dicpp&#x2F;src&#x2F;HEAD&#x2F;lib&#x2F;examples&#x2F;stoc...</a>) I&#x27;m all ears.<p>There was one posted on the Boost list not so long ago which was VERY promising but I haven&#x27;t managed to get around to using it yet.
malisperover 10 years ago
Can someone explain what exactly the library does? All I got from the description is something about a way of building an argument list, and then how it is possible to fulfill some dependencies with factories or make methods or something.
评论 #8838194 未加载
评论 #8838186 未加载
matt42over 10 years ago
The source code is here, interesting if you enjoy c++14 meta programming: <a href="https://github.com/matt-42/iod/blob/master/iod/di.hh" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;matt-42&#x2F;iod&#x2F;blob&#x2F;master&#x2F;iod&#x2F;di.hh</a>
评论 #8834819 未加载
评论 #8834780 未加载
ameliusover 10 years ago
What baffles me is this: Why does such a (conceptually) simple thing require such a hairy implementation?
评论 #8835026 未加载
评论 #8838175 未加载
评论 #8834850 未加载