The very simple code below compiles and links without a warning in C++98 but gives an incomprehensible compile error in C++11 mode.
#include
The copy constructor of std::pair
isn't needed in this case, but because it is default defined inline in the declaration of std::pair
, it is automatically instantiated along with the instantiation of std::pair
itself.
It would be possible for the standard library to provide a non-inline default definition of the copy constructor:
template
struct pair
{
// ...
constexpr pair(const pair&);
// ...
};
// ...
template
constexpr pair<_T1, _T2>::pair(const pair&) = default;
However this would not accord with the strict letter of the standard (clause 20.3.2), where the copy constructor is default defined inline:
constexpr pair(const pair&) = default;