I mean why does std::make_tuple
exist? I know that there are situations where the function reduces the amount of characters you have to type because you can avoid template parameters. But is it the only reason? What makes std::tuple
special that the function exists while other class templates haven't such function? Is it only because you may use std::tuple
more often in such situations?
Here are two examples where std::make_tuple
reduces the amount of characters:
// Avoiding template parameters in definition of variable.
// Consider that template parameters can be very long sometimes.
std::tuple<int, double> t(0, 0.0); // without std::make_tuple
auto t = std::make_tuple(0, 0.0); // with std::make_tuple
// Avoiding template parameters at construction.
f(std::tuple<int, double>(0, 0.0)); // without std::make_tuple
f(std::make_tuple(0, 0.0)); // with std::make_tuple
But like written above, you don't have a function like this for many other class templates.