hi,
what is it for?
stl docu says
template <class T1, class T2>
pair<T1, T2> make_pair(const T1& x, const T2& y)
Equivalent to pair<T1, T2>(x, y). This is a global function, not a member function. It exists only for the sake of
convenience.
looking at the implementation of the VS2005 stl is seems to do something else:
Code:
template<class _Ty1,
class _Ty2> inline
pair<_Ty1, _Ty2> make_pair(_Ty1 _Val1, _Ty2 _Val2)
{ // return pair composed from arguments
return (pair<_Ty1, _Ty2>(_Val1, _Val2));
}
it takes the pair members by value instead of const reference adding 2 copy constructor calls to one constructor call to pair(), a copy constructor call for the the return by value and another copy constructor call if the client code also catches by value instead of by const reference ... compared to a singe constructor call to pair().
what kind of convenience is this? has std::make_pair any sense/advantage in any situation?
thank you!