What is the purpose of std::make_pair?
Why not just do std::pair?
Is there any difference between the tw
make_pair creates an extra copy over the direct constructor. I always typedef my pairs to provide simple syntax.
This shows the difference (example by Rampal Chaudhary):
class Sample
{
static int _noOfObjects;
int _objectNo;
public:
Sample() :
_objectNo( _noOfObjects++ )
{
std::cout<<"Inside default constructor of object "<<_objectNo< map;
map.insert( std::make_pair( 1, sample) );
//map.insert( std::pair( 1, sample) );
return 0;
}