-
1741 votesanswersviews
什么是复制和交换习语?
这个成语是什么?何时应该使用?它解决了哪些问题?当使用C 11时,成语是否会改变? 虽然在很多地方已经提到过,但我们没有任何单一的“它是什么”的问题和答案,所以在这里 . 以下是前面提到过的地方的部分列表: What are your favorite C++ Coding Style idioms: Copy-swap Copy constructor and = operator ov... -
127 votesanswersviews
公共交换成员函数
在copy-and-swap-idiom的漂亮答案中,有一段代码我需要一些帮助: class dumb_array { public: // ... friend void swap(dumb_array& first, dumb_array& second) // nothrow { using std::swap; sw...