I am trying to do something like this:
struct Foo {
int _val;
Foo(int v) : _val(v){}
};
struct Bar {
const std::string &_name;
Bar(const std::string &name) : _name(name) {}
};
template<typename T>
struct Universal {
T _t;
Universal(...) : _t(...) {}
};
// I want to use Universal for Foo abd Bar in the same way:
Universal<Foo> UF(9); // 9 is for Foo
Universal<Bar> UB("hello"); // "hello" is for bar
In the code above, I would like to forward all parameters in Universal's constructor to T's constructor.
How could I do it?