Link to code: compiler_explorer
I have a templated class with three parameters: int, typename, template <typename> typename
. For this class I want to provide just the first parameter, the int: eg: Obj<1>
.
I am trying to have the compiler deduce the second and third parameters via the constructor.
template <typename... Args> struct dummy{};
template <int dummy_parameter, typename T, template <typename> typename S>
struct Obj
{
explicit Obj(S<T>* some_data) : data{ some_data } {}
S<T>* data;
};
template <typename T, template <typename> typename S>
struct Obj2
{
explicit Obj2(S<T>* some_data) : data{ some_data } {}
S<T>* data;
};
int main()
{
dummy<double>* x;
Obj2 obj2{ x }; // deduces the parameters
Obj<1> obj{ x }; // doesn't deduce anymore, why?
}
How to I manage to get the second and third parameters deduced by the compiler? Is this possible?