From 849ce05b81e9c29affdb3d0e7a4b52587f905414 Mon Sep 17 00:00:00 2001
From: changdingfang <245292011@qq.com>
Date: Mon, 24 Aug 2020 10:49:21 +0800
Subject: [PATCH] fix code errors
---
book/en-us/07-thread.md | 4 +++-
book/zh-cn/04-containers.md | 16 ++++++++--------
book/zh-cn/07-thread.md | 2 ++
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/book/en-us/07-thread.md b/book/en-us/07-thread.md
index 4ee91602..a2032d1a 100644
--- a/book/en-us/07-thread.md
+++ b/book/en-us/07-thread.md
@@ -314,6 +314,8 @@ struct A {
int y;
long long z;
};
+
+int main() {
std::atomic a;
std::cout << std::boolalpha << a.is_lock_free() << std::endl;
return 0;
@@ -546,4 +548,4 @@ They provide an critical foundation for standardized high performance computing
## Licenses
-
This work was written by [Ou Changkun](https://changkun.de) and licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. The code of this repository is open sourced under the [MIT license](../../LICENSE).`
\ No newline at end of file
+
This work was written by [Ou Changkun](https://changkun.de) and licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. The code of this repository is open sourced under the [MIT license](../../LICENSE).`
diff --git a/book/zh-cn/04-containers.md b/book/zh-cn/04-containers.md
index 219676b0..a9999a66 100644
--- a/book/zh-cn/04-containers.md
+++ b/book/zh-cn/04-containers.md
@@ -186,14 +186,14 @@ Key:[3] Value:[3]
auto get_student(int id)
{
-// 返回类型被推断为 std::tuple
-
-if (id == 0)
- return std::make_tuple(3.8, 'A', "张三");
-if (id == 1)
- return std::make_tuple(2.9, 'C', "李四");
-if (id == 2)
- return std::make_tuple(1.7, 'D', "王五");
+ // 返回类型被推断为 std::tuple
+
+ if (id == 0)
+ return std::make_tuple(3.8, 'A', "张三");
+ if (id == 1)
+ return std::make_tuple(2.9, 'C', "李四");
+ if (id == 2)
+ return std::make_tuple(1.7, 'D', "王五");
return std::make_tuple(0.0, 'D', "null");
// 如果只写 0 会出现推断错误, 编译失败
}
diff --git a/book/zh-cn/07-thread.md b/book/zh-cn/07-thread.md
index 9dd58ae6..b02daa07 100644
--- a/book/zh-cn/07-thread.md
+++ b/book/zh-cn/07-thread.md
@@ -321,6 +321,8 @@ struct A {
int y;
long long z;
};
+
+int main() {
std::atomic a;
std::cout << std::boolalpha << a.is_lock_free() << std::endl;
return 0;