thank you very much for this wonderful library. Aftrer some time now, I have again picked-up re-investigating the library. I have hit some problems in a toy project where I simply do not know how I am supposed to solve it with the tools provided. Therefore, I would like to ask you to give me some hints and consdering to extend or improve the documentation.
Following, is an extracted minimal example of the problem.
Assume, we have some types wrapping an external API
Finally, we want to create an application holding some state
struct Application
{
Device& device;
//ShaderModule<ShaderType::Vertex>& vertexShader;
//ShaderModule<ShaderType::Fragment>& fragmentShader;
};
int main(int, char**)
{
auto injector = di::make_injector(
// ? what to put here?
// How to bind ShaderModule<ShaderType::Vertex> using ShaderFile { "hello" }
// and ShaderModule<ShaderType::Fragment> using StaticShaderCode?
);
auto application = injector.create<Application>();
std::cout << Device::constructed << " devices created";
assert(Device::constructed == 1u);
std::cout << std::endl;
}
The code is really just a toy to illustrate the problem I am trying to solve. The class design is most probably not the best, but I think there should be a way to handle this in DI.
I tried using placeholders, but that failed to compile
Hello,
thank you very much for this wonderful library. Aftrer some time now, I have again picked-up re-investigating the library. I have hit some problems in a toy project where I simply do not know how I am supposed to solve it with the tools provided. Therefore, I would like to ask you to give me some hints and consdering to extend or improve the documentation.
Following, is an extracted minimal example of the problem. Assume, we have some types wrapping an external API
Then, we create some interface implementation
and some wrappers to increase type-safety
Finally, we want to create an application holding some state
The code is really just a toy to illustrate the problem I am trying to solve. The class design is most probably not the best, but I think there should be a way to handle this in DI.
I tried using placeholders, but that failed to compile
I tried binding lambdas or creating modules, but I don't really know how to do that properly.
I would be really glad hearing how you think this should be done.
Kind regards
Konstantin