In C++17, it will be possible to instantiate objects without specifying the template types. Basically, this code would compile:
std::pair p(2, 4.5); // deduces to std::pair<int, double> p(2, 4.5);
std::tuple t(4, 3, 2.5); // same as auto t = std::make_tuple(4, 3, 2.5);
So, assuming this code below:
template<typename... Ts>
struct Foo
{
Foo(Ts&&... ts) :
ts{std::forward_as_tuple(ts...)}
{}
std::tuple<Ts...> ts;
};
int main()
{
auto f = [] { return 42; };
Foo foo{f, [] { return 84; }};
}
Should I use std::decay
in the tuple declaration like this?
std::tuple<std::decay_t<Ts>...> ts;
Because this is how I'd write a function to return an object based on the deduced template type:
template<typename T>
auto make_baz(T&& t) -> baz<std::decay_t<T>>;
And I can see this pattern in the Foo's constructor, where it's using forwarding references to correctly pass the values to the tuple. I'm not sure if the type deduction here behaves the same way.