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 7529ae3a55
636 changed files with 10025 additions and 9387 deletions

26
cpp2.0/cpp11/noexcept.cpp Normal file
View File

@@ -0,0 +1,26 @@
//
// Created by light on 19-11-3.
//
#include <iostream>
#include <vector>
using namespace std;
// noexcepte ()中可以加条件
// 异常可传递 a调用b b抛出异常,a没处理,就会抛出异常
// 1.异常的回传机制:调用foo如果抛出异常foo会接着往上层抛出异常
// 如果最上层没有处理则会调用terminate函数terminate函数内部调用abort使程序退出
// 2.在使用vector deque等容器的移动构造和移动赋值的时候如果移动构造和移动赋值没有加上noexcept
// 则容器增长的时候不会调用move constructor效率就会偏低所以后面需要加上noexcept安心使用。
void foo() noexcept(true) {
}
int main() {
foo();
vector<int> vec;
return 0;
}