How does make_pair know the types of its args?
Posted
by bobobobo
on Stack Overflow
See other posts from Stack Overflow
or by bobobobo
Published on 2010-04-19T22:59:35Z
Indexed on
2010/04/19
23:03 UTC
Read the original article
Hit count: 154
The definition for make_pair in the MSVC++ "utility" header is:
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)); }
I use make_pair all the time though without putting the argument types in angle brackets:
map<string,int> theMap ; theMap.insert( make_pair( "string", 5 ) ) ;
Shouldn't I have to tell make_pair
that the first argument is std::string
and not char*
?
How does it know?
© Stack Overflow or respective owner