reserve 以后有几个元素
运行下面这段程序:
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
int main() {
vector<int> v;
v.reserve(100);
cout << v.size() << "/" << (v.capacity() >= 100) << endl;
}
(本题用 g++ -std=c++17 -O0 编译。)
全部评论