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
std::map
uses std::pair
to store key-value pairs, where the key (the first element) is const
.
The compiler error relates to the required copy constructor for std::pair
, even if it isn't being used (which I don't think it is).
std::pair
has to be generated. This is first required with the call to map::begin.
Since no explicit copy constructor is given for this type, the implicit one used.
The implicit constructor will have signature T::T(const T&) only if all non-static members of T, (type S), have copy constructors S::S(const S&) (the same requirement has to hold for T's base types copy constructors). Otherwise a copy constructor with signature T::T(T&) is used instead.
A's copy constructor fails this requirement, so std::pair::pair has the wrong signature for the STL, which requires T::T(const T&).