Questions tagged «swap»

更改两个项目的位置。

1
为什么仅当我的容器包含32个以上元素时,std :: sort才会调用swap?
您好,我有一个简单的问题: class A { public: A(int); A(const A&); A& operator=(const A&); ~A(); private: int* ptr_; friend bool operator<(const A&, const A&); friend void swap(A&, A&); }; A::A(int x) : ptr_(new int(x)) {} A::A(const A& rhs) : ptr_(rhs.ptr_ ? new int(*rhs.ptr_) : nullptr) {} A& A::operator = (const A & rhs) …
13 c++  std  swap 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.