c++ - template member of std::pair<> must have const copy constructor. How to implement that constraint -
c++11 standard require template member of std::pair<> must have const copy constructor. otherwise, not compile.(from book the c++ standard library , nicolai m. josuttis.). so, code below wouldn't compile if it's against c++11 standard: class a{ int i; public: a(){} a(a&){} }; int main(){ pair<int, a> p; } with -std=c++11 , g++ compiler report error: constexpr std::pair<_t1, _t2>::pair(const std::pair<_t1, _t2>&) [with _t1 = int; _t2 = a]' declared take const reference, implicit declaration take non-const: constexpr pair(const pair&) = default that because declare a's copy constructor non-const. if change a(a&){} a(const a&){} , or remove -std=c++11 flag, fine. my question is, how constaint implemented? can see no support in language provide inside template parameter t . mean, declared this: template<typename t1, typename t2> class pair{ ... //how...