support bazel complie this project and format code.

This commit is contained in:
zhangxing
2023-03-30 00:15:11 +08:00
committed by light-city
parent 1f86192576
commit 3c8a3f259b
641 changed files with 10349 additions and 9523 deletions

View File

@@ -0,0 +1,45 @@
//
// Created by light on 19-12-16.
//
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
class Obj1 {
public:
Obj1() { cout << "Obj1()\n"; }
Obj1(const Obj1 &) { cout << "Obj1(const Obj1&)\n"; }
Obj1(Obj1 &&) { cout << "Obj1(Obj1&&)\n"; }
};
class Obj2 {
public:
Obj2() { cout << "Obj2()\n"; }
Obj2(const Obj2 &) { cout << "Obj2(const Obj2&)\n"; }
Obj2(Obj2 &&) noexcept { cout << "Obj2(Obj2&&)\n"; }
};
int main() {
vector<int> v;
int nums = 20;
for (int i = 0; i < nums; ++i) {
v.push_back(i + 1);
cout << "v_size: " << v.size() << "\t v_capacity: " << v.capacity() << endl;
}
// 头两个在已有空间上成功构造。第三个时发现空间不足,系统会请求更大的空间,大小由实现决定(比如两倍)。
// 有了足够的空间后就会在新空间的第三个的位置构造第三个obj1成功之后再把头两个拷贝或移动过来。
vector<Obj1> v1;
// v1.reserve(2);
v1.emplace_back();
v1.emplace_back();
v1.emplace_back();
v1.emplace_back();
vector<Obj2> v2;
v2.reserve(2);
v2.emplace_back();
v2.emplace_back();
v2.emplace_back();
}