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 avo
Because you cannot use argument deduction for constructors. You need to write explicitly std::tuple
.
It makes it more convenient for creating a tuple and passing it to another function in one-shot.
takes_tuple(make_tuple(i,d))
vs takes_tuple(tuple
.
One less place to change when the type of i
or d
changes, especially if there were possible conversions to between the old and new types.
If it were possible to write std::tuple(i,d);
, make_*
would (probably) be redundant.
(Don't ask why here. Maybe for similar reasons why syntax A a();
does not invoke a default constructor. There are some painful c++ syntax peculiarities.)
UPDATE NOTE: As Daniel rightly notices, c++17 will be enhanced, so that template argument deduction will work for constructors, and such delegation will become obsolete.