It first creates a std::pair<double, char>
thanks to type deduction of the helper function std::make_pair
which creates a pair of exactly the same types than you passed to it, no matter to which type you later assign this pair to.
This object gets then assigned to a std::pair<int,int>
which works thanks to a templated assignment operator. This operator basically allows assignable types (U1
to T1
, U2
to T2
) which internally assigns (in your case) a double
to an int
and a char
to an int
.
The language doesn't have a feature which "forecasts" the type of variable where the expression will be used, which would be required to make a pair<int,int>
immediately without this step in between.
If you want to avoid that step you have to be explicit when constructing the pair, meaning that you shouldn't use the type deducting std::make_pair
but rather std::pair
's constructor which requires you to put the explicit types. However, I doubt this will increase performance thanks to optimization.