Right now, construct is either not a template or a function template of this particular form:
template<typename... Args>
static auto construct(<services...>, Args&&...)
It is required right now that all forwarded argument fits into the pack. As such, this kind of form is not allowed:
// inside SomeService
template<typename... Args>
static auto construct(<services...>, int additionnalParameter1, Args&&...)
if we call service that way:
container.service<SomeService>(2, "some other arg", 3.2);
The logical thing to do would be to forward the int
with the value of 2
to the parameter named additionnalParameter1
. The container would have to deduce the pack to be {const char*, 3.2}
, but right now uses all parameter to be in the pack, and will try to call construct<int, const char* 3.2>
. Obviously the call fails.
The idea would be try different form of template parameter matching, validating the match by using sfinae. At first, we could allow the form we talked about here, dropping parameters from the pack one by one and try to call the function. Maybe later we could allow more forms of template function, but may slow down compilation.