clear 以后容量还在吗
运行下面这段程序:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
vector<int> v = {3, 7, 5};
v.clear();
cout << v.size() << "/" << (v.capacity() >= 3 ? "容量还在" : "容量没了") << endl;
}
(本题用 g++ -std=c++17 -O0 编译。)
全部评论