I would like a template class to automatically pick it’s parameter based on the type of class passed to the constructor.
objects already have types.
InputA a;
InputA a2;
InputB b;
these types should be understood by constructors
out<>(a) out;
is
out<InputA>(a) out;
.
out<>(a2) out;
is
out<InputA>(a2) out;
.
out<>(b) out;
is
out<InputB>(b) out;
it seems redundant to define the template argument (the policy) when this can be extracted from the type of the input parameter.
This is the same problem that happend with
std::pair.The standard workaround for this problem is to define a template factory (like
std::make_pair()).e.g.