13.29
因为传入的形参不同,调用的是不同的函数
13.30
13.31
bool operator < (HasPtr& has) const { return this->i < has.i; }
void swap(HasPtr& h1, HasPtr& h2){ cout << "function HasPtr swap running" << endl; std::swap(h1.i, h2.i); std::swap(h1.ps, h2.ps); }
测试时,需要往vec添加一定数量的元素才会使用自定义的swap,否则会使用插入排序
13.32
收益是有,很小,类指针的指针已经指向同一片内存,实际操作来说只会交换成员变量,收益取决于成员变量的数量