1. swap是STL的一部分,后来成为异常安全性编程(exception-safe programming)(见条款29)的一个重要脊柱,标准库的swap函数模板定义类似以下:

namespace std{
    template<typename T>
    swap(T& lhs,T& rhs){
        T temp(lhs);
        lhs=rhs;
        rhs=temp;
    }
}
View Code

相关文章:

  • 2022-02-21
  • 2022-12-23
  • 2021-10-03
  • 2022-12-23
  • 2021-11-07
  • 2022-02-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2021-12-16
  • 2022-01-26
  • 2021-07-06
相关资源
相似解决方案