Why std::pair requires both pair( const T1& x, const T2& y ); and pair( U1&& x, U2&& y );

Viewed 61

std::pair has two constructors:

  1. pair( const T1& x, const T2& y );
    
  2. template< class U1, class U2 >
    pair( U1&& x, U2&& y );
    

I learned universal reference from Effective Modern C++ and know why requires #2 and how does it work. But I cannot understand why #1 is still required and consider #2 can replace #1 100%. I believe that I must miss something critical knowledge.

0 Answers
Related