Hey all. Long time no see. Sadly I don't have the time to keep up with these forums like I used to. =( But I had a C++ question and figured the people here could help!
I want to do something like this:
1 2 3 4 5
template <typename T, ??? > // <- not sure what should go in the '???'
T* func( ??? )
{
returnnew T( ??? );
}
The idea being, 'func' takes any number of parameters, of any type. And I want all those extra parameters to be forwarded to the constructor of my T object. Similar to what make_unique does.
The end result being:
1 2 3 4
Foo* p = func<Foo>(1, "whatever", someobj);
// is the same as
Foo* p = new Foo(1, "whatever", someobj);
I never fully wrapped my head around variadic templates, and this is kind of a huge blind spot for me. Does anyone know how to accomplish this?