From 79d7e3e82a0ae27032d380dc95bf0b5b78b6b7d1 Mon Sep 17 00:00:00 2001 From: Leslie Zhu Date: Fri, 4 Aug 2023 17:12:33 +0800 Subject: [PATCH] update --- 2019/08/29/tensorflow_1.html | 6 +- ...\347\247\257\351\233\250\344\272\221.html" | 6 +- 2019/12/29/about_CStdString.html | 6 +- 2020/05/10/I_want_a_dictionary.html | 6 +- 2022/05/19/CuiHao.html | 6 +- 2022/06/19/TangChaoHuangDiJieShao.html | 6 +- 2022/06/20/LiZhong.html | 6 +- 2022/06/22/TangXuanZong.html | 6 +- 2022/10/18/NanChaoGuShiRenWu_01.html | 6 +- 2022/10/18/unzip.html | 6 +- 2022/10/22/cpp_1.html | 6 +- 2022/10/23/cpp_2.html | 6 +- 2022/10/24/yum_rpm.html | 6 +- 2022/10/25/cpp_3.html | 6 +- 2022/10/26/cpp_4.html | 6 +- 2022/10/26/cpp_5.html | 6 +- 2022/10/26/cpp_6.html | 6 +- 2022/10/31/cpp_7.html | 6 +- 2022/11/01/cpp_8.html | 6 +- 2022/11/01/cpp_9.html | 6 +- 2022/11/04/cpp_10.html | 6 +- .../10/writing_an_interpreter_in_cpp_1.html | 6 +- .../11/writing_an_interpreter_in_cpp_2.html | 6 +- 2022/11/12/delete_file_with_shred.html | 6 +- .../13/writing_an_interpreter_in_cpp_3.html | 6 +- 2022/11/16/cpp_go_to_wrong_1.html | 6 +- 2022/11/17/git_subtree_and_submodule.html | 6 +- 2022/11/20/TMOUT_env_variable_in_liunux.html | 6 +- 2022/11/21/PAM_in_linux.html | 6 +- 2022/11/21/man_pages_missing.html | 6 +- .../21/writing_an_interpreter_in_cpp_4.html | 6 +- .../24/writing_an_interpreter_in_cpp_5.html | 6 +- .../26/writing_an_interpreter_in_cpp_6.html | 6 +- 2022/12/11/be_a_guest_tomorrow.html | 6 +- .../12/writing_an_interpreter_in_cpp_7.html | 6 +- .../12/writing_an_interpreter_in_cpp_8.html | 6 +- .../13/writing_an_interpreter_in_cpp_9.html | 6 +- .../16/writing_an_interpreter_in_cpp_10.html | 6 +- .../16/writing_an_interpreter_in_cpp_11.html | 6 +- .../16/writing_an_interpreter_in_cpp_12.html | 6 +- 2022/12/17/llvm_1.html | 6 +- 2022/12/19/git_clang_format.html | 6 +- .../27/bytecode_serializer_deserializer.html | 6 +- 2022/12/28/dockerfile_for_ledge.html | 6 +- 2022/12/29/torch_dragon.html | 6 +- 2023/01/02/gnu_readline_in_repl.html | 6 +- 2023/01/06/learn_japanese_1.html | 6 +- 2023/01/07/a_special_call_name_of_hakka.html | 6 +- ...ree_Essays_On_The_Theory_Of_Sexuality.html | 6 +- 2023/01/23/field_under_the_sun.html | 6 +- 2023/01/28/learn_japanese_2.html | 6 +- 2023/01/29/learn_japanese_3.html | 6 +- 2023/01/31/protobuf.html | 6 +- 2023/02/03/tensorflow_2.html | 6 +- 2023/03/01/doxygen_work_with_cmake.html | 6 +- 2023/03/03/use_StableDiffusion_gen_photo.html | 6 +- ...ffusion_gen_photo_with_gpu_on_windows.html | 6 +- 2023/03/15/faceswap_1.html | 6 +- 2023/03/23/learn_japanese_4.html | 6 +- 2023/04/13/yin_keng.html | 6 +- 2023/05/31/hu_bian_de_mo_chou_nv.html | 6 +- 2023/07/04/travel_202351.html | 8 +- 2023/08/01/junzibaobian.html | 289 ++++++++++++++++++ about.html | 12 +- archive.html | 10 +- calendar.html | 6 +- index.html | 20 +- links.html | 6 +- page1.html | 20 +- page2.html | 13 +- rss.xml | 11 + search.json | 2 +- tags.html | 2 +- tags/201910.html | 6 +- tags/202005.html | 6 +- tags/202205.html | 6 +- tags/202206.html | 6 +- tags/202210.html | 6 +- tags/202211.html | 6 +- tags/202212.html | 6 +- tags/202301.html | 6 +- tags/202302.html | 6 +- tags/202303.html | 6 +- tags/202304.html | 6 +- tags/202305.html | 6 +- tags/202307.html | 6 +- tags/202308.html | 218 +++++++++++++ ...\344\270\216\345\256\236\350\267\265.html" | 6 +- ...\344\270\216\347\256\241\347\220\206.html" | 6 +- ...\345\215\227\351\207\216\351\233\206.html" | 6 +- ...\345\267\245\346\231\272\350\203\275.html" | 6 +- ...\350\257\255\345\255\246\344\271\240.html" | 6 +- ...\347\274\226\350\257\221\345\231\250.html" | 6 +- ...\347\254\224\346\234\255\350\256\260.html" | 8 +- 94 files changed, 815 insertions(+), 290 deletions(-) create mode 100644 2023/08/01/junzibaobian.html create mode 100644 tags/202308.html diff --git a/2019/08/29/tensorflow_1.html b/2019/08/29/tensorflow_1.html index e759ffe7..924d8ce0 100644 --- a/2019/08/29/tensorflow_1.html +++ b/2019/08/29/tensorflow_1.html @@ -444,21 +444,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git "a/2019/10/17/\347\247\257\351\233\250\344\272\221.html" "b/2019/10/17/\347\247\257\351\233\250\344\272\221.html" index 4a0e0b9a..5f8229b2 100644 --- "a/2019/10/17/\347\247\257\351\233\250\344\272\221.html" +++ "b/2019/10/17/\347\247\257\351\233\250\344\272\221.html" @@ -577,21 +577,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2019/12/29/about_CStdString.html b/2019/12/29/about_CStdString.html index 15892dc1..bf75f414 100644 --- a/2019/12/29/about_CStdString.html +++ b/2019/12/29/about_CStdString.html @@ -298,21 +298,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2020/05/10/I_want_a_dictionary.html b/2020/05/10/I_want_a_dictionary.html index 0826e99e..602f621c 100644 --- a/2020/05/10/I_want_a_dictionary.html +++ b/2020/05/10/I_want_a_dictionary.html @@ -481,21 +481,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/05/19/CuiHao.html b/2022/05/19/CuiHao.html index a9dd2d1b..daade5f6 100644 --- a/2022/05/19/CuiHao.html +++ b/2022/05/19/CuiHao.html @@ -193,21 +193,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/06/19/TangChaoHuangDiJieShao.html b/2022/06/19/TangChaoHuangDiJieShao.html index 118fd8c0..011ef5c5 100644 --- a/2022/06/19/TangChaoHuangDiJieShao.html +++ b/2022/06/19/TangChaoHuangDiJieShao.html @@ -324,21 +324,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/06/20/LiZhong.html b/2022/06/20/LiZhong.html index d46aab16..fb829857 100644 --- a/2022/06/20/LiZhong.html +++ b/2022/06/20/LiZhong.html @@ -195,21 +195,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/06/22/TangXuanZong.html b/2022/06/22/TangXuanZong.html index 748b3d75..229db55b 100644 --- a/2022/06/22/TangXuanZong.html +++ b/2022/06/22/TangXuanZong.html @@ -447,21 +447,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/10/18/NanChaoGuShiRenWu_01.html b/2022/10/18/NanChaoGuShiRenWu_01.html index 074bcc8e..bf732d1b 100644 --- a/2022/10/18/NanChaoGuShiRenWu_01.html +++ b/2022/10/18/NanChaoGuShiRenWu_01.html @@ -189,21 +189,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/10/18/unzip.html b/2022/10/18/unzip.html index a688b5a3..c6ed2d29 100644 --- a/2022/10/18/unzip.html +++ b/2022/10/18/unzip.html @@ -229,21 +229,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/10/22/cpp_1.html b/2022/10/22/cpp_1.html index 39d6be6d..8c0c391e 100644 --- a/2022/10/22/cpp_1.html +++ b/2022/10/22/cpp_1.html @@ -518,21 +518,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/10/23/cpp_2.html b/2022/10/23/cpp_2.html index 9c5e80cc..be9506d4 100644 --- a/2022/10/23/cpp_2.html +++ b/2022/10/23/cpp_2.html @@ -794,21 +794,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/10/24/yum_rpm.html b/2022/10/24/yum_rpm.html index 409781a2..51663535 100644 --- a/2022/10/24/yum_rpm.html +++ b/2022/10/24/yum_rpm.html @@ -671,21 +671,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/10/25/cpp_3.html b/2022/10/25/cpp_3.html index 22025536..75691fe6 100644 --- a/2022/10/25/cpp_3.html +++ b/2022/10/25/cpp_3.html @@ -591,21 +591,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/10/26/cpp_4.html b/2022/10/26/cpp_4.html index 6822594b..ab8e2923 100644 --- a/2022/10/26/cpp_4.html +++ b/2022/10/26/cpp_4.html @@ -601,21 +601,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/10/26/cpp_5.html b/2022/10/26/cpp_5.html index b726a434..03b6a74e 100644 --- a/2022/10/26/cpp_5.html +++ b/2022/10/26/cpp_5.html @@ -553,21 +553,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/10/26/cpp_6.html b/2022/10/26/cpp_6.html index e8e6b491..1bb8ba38 100644 --- a/2022/10/26/cpp_6.html +++ b/2022/10/26/cpp_6.html @@ -532,21 +532,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/10/31/cpp_7.html b/2022/10/31/cpp_7.html index db49dfbf..622fa6c4 100644 --- a/2022/10/31/cpp_7.html +++ b/2022/10/31/cpp_7.html @@ -384,21 +384,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/11/01/cpp_8.html b/2022/11/01/cpp_8.html index 6fb96d48..a0621d01 100644 --- a/2022/11/01/cpp_8.html +++ b/2022/11/01/cpp_8.html @@ -294,21 +294,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/11/01/cpp_9.html b/2022/11/01/cpp_9.html index de6b7504..bbf29ec2 100644 --- a/2022/11/01/cpp_9.html +++ b/2022/11/01/cpp_9.html @@ -397,21 +397,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/11/04/cpp_10.html b/2022/11/04/cpp_10.html index 32f16dc1..6963c506 100644 --- a/2022/11/04/cpp_10.html +++ b/2022/11/04/cpp_10.html @@ -427,21 +427,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/11/10/writing_an_interpreter_in_cpp_1.html b/2022/11/10/writing_an_interpreter_in_cpp_1.html index dddf5362..96fded47 100644 --- a/2022/11/10/writing_an_interpreter_in_cpp_1.html +++ b/2022/11/10/writing_an_interpreter_in_cpp_1.html @@ -308,21 +308,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/11/11/writing_an_interpreter_in_cpp_2.html b/2022/11/11/writing_an_interpreter_in_cpp_2.html index 13d28fa1..e1b3fd41 100644 --- a/2022/11/11/writing_an_interpreter_in_cpp_2.html +++ b/2022/11/11/writing_an_interpreter_in_cpp_2.html @@ -531,21 +531,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/11/12/delete_file_with_shred.html b/2022/11/12/delete_file_with_shred.html index 21ba1fb6..57aad8dc 100644 --- a/2022/11/12/delete_file_with_shred.html +++ b/2022/11/12/delete_file_with_shred.html @@ -342,21 +342,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/11/13/writing_an_interpreter_in_cpp_3.html b/2022/11/13/writing_an_interpreter_in_cpp_3.html index 983e9d36..249414b8 100644 --- a/2022/11/13/writing_an_interpreter_in_cpp_3.html +++ b/2022/11/13/writing_an_interpreter_in_cpp_3.html @@ -770,21 +770,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/11/16/cpp_go_to_wrong_1.html b/2022/11/16/cpp_go_to_wrong_1.html index 0e27f19e..d2b3e375 100644 --- a/2022/11/16/cpp_go_to_wrong_1.html +++ b/2022/11/16/cpp_go_to_wrong_1.html @@ -246,21 +246,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/11/17/git_subtree_and_submodule.html b/2022/11/17/git_subtree_and_submodule.html index 7cf4b360..c08f4149 100644 --- a/2022/11/17/git_subtree_and_submodule.html +++ b/2022/11/17/git_subtree_and_submodule.html @@ -223,21 +223,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/11/20/TMOUT_env_variable_in_liunux.html b/2022/11/20/TMOUT_env_variable_in_liunux.html index c2d7440c..e0782cbb 100644 --- a/2022/11/20/TMOUT_env_variable_in_liunux.html +++ b/2022/11/20/TMOUT_env_variable_in_liunux.html @@ -238,21 +238,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/11/21/PAM_in_linux.html b/2022/11/21/PAM_in_linux.html index 58dc7fe7..19ae73a6 100644 --- a/2022/11/21/PAM_in_linux.html +++ b/2022/11/21/PAM_in_linux.html @@ -414,21 +414,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/11/21/man_pages_missing.html b/2022/11/21/man_pages_missing.html index c3b49614..81e63fcf 100644 --- a/2022/11/21/man_pages_missing.html +++ b/2022/11/21/man_pages_missing.html @@ -217,21 +217,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/11/21/writing_an_interpreter_in_cpp_4.html b/2022/11/21/writing_an_interpreter_in_cpp_4.html index 353688eb..968814f8 100644 --- a/2022/11/21/writing_an_interpreter_in_cpp_4.html +++ b/2022/11/21/writing_an_interpreter_in_cpp_4.html @@ -931,21 +931,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/11/24/writing_an_interpreter_in_cpp_5.html b/2022/11/24/writing_an_interpreter_in_cpp_5.html index ab57349e..0b5814ac 100644 --- a/2022/11/24/writing_an_interpreter_in_cpp_5.html +++ b/2022/11/24/writing_an_interpreter_in_cpp_5.html @@ -824,21 +824,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/11/26/writing_an_interpreter_in_cpp_6.html b/2022/11/26/writing_an_interpreter_in_cpp_6.html index e1e25632..fc4e9d2a 100644 --- a/2022/11/26/writing_an_interpreter_in_cpp_6.html +++ b/2022/11/26/writing_an_interpreter_in_cpp_6.html @@ -634,21 +634,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/12/11/be_a_guest_tomorrow.html b/2022/12/11/be_a_guest_tomorrow.html index be8cc5a7..421130d4 100644 --- a/2022/12/11/be_a_guest_tomorrow.html +++ b/2022/12/11/be_a_guest_tomorrow.html @@ -195,21 +195,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/12/12/writing_an_interpreter_in_cpp_7.html b/2022/12/12/writing_an_interpreter_in_cpp_7.html index bc042d48..c4974e0e 100644 --- a/2022/12/12/writing_an_interpreter_in_cpp_7.html +++ b/2022/12/12/writing_an_interpreter_in_cpp_7.html @@ -691,21 +691,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/12/12/writing_an_interpreter_in_cpp_8.html b/2022/12/12/writing_an_interpreter_in_cpp_8.html index 1b5fac16..6015fdaf 100644 --- a/2022/12/12/writing_an_interpreter_in_cpp_8.html +++ b/2022/12/12/writing_an_interpreter_in_cpp_8.html @@ -658,21 +658,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/12/13/writing_an_interpreter_in_cpp_9.html b/2022/12/13/writing_an_interpreter_in_cpp_9.html index 9e8cbc67..e1eb5035 100644 --- a/2022/12/13/writing_an_interpreter_in_cpp_9.html +++ b/2022/12/13/writing_an_interpreter_in_cpp_9.html @@ -901,21 +901,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/12/16/writing_an_interpreter_in_cpp_10.html b/2022/12/16/writing_an_interpreter_in_cpp_10.html index 219834d4..a4a5394a 100644 --- a/2022/12/16/writing_an_interpreter_in_cpp_10.html +++ b/2022/12/16/writing_an_interpreter_in_cpp_10.html @@ -445,21 +445,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/12/16/writing_an_interpreter_in_cpp_11.html b/2022/12/16/writing_an_interpreter_in_cpp_11.html index 20e0195b..14945b3d 100644 --- a/2022/12/16/writing_an_interpreter_in_cpp_11.html +++ b/2022/12/16/writing_an_interpreter_in_cpp_11.html @@ -638,21 +638,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/12/16/writing_an_interpreter_in_cpp_12.html b/2022/12/16/writing_an_interpreter_in_cpp_12.html index bdd2ead5..3334ebcd 100644 --- a/2022/12/16/writing_an_interpreter_in_cpp_12.html +++ b/2022/12/16/writing_an_interpreter_in_cpp_12.html @@ -254,21 +254,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/12/17/llvm_1.html b/2022/12/17/llvm_1.html index f0ac0c7a..3d570c68 100644 --- a/2022/12/17/llvm_1.html +++ b/2022/12/17/llvm_1.html @@ -217,21 +217,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/12/19/git_clang_format.html b/2022/12/19/git_clang_format.html index 962db846..56705e22 100644 --- a/2022/12/19/git_clang_format.html +++ b/2022/12/19/git_clang_format.html @@ -239,21 +239,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/12/27/bytecode_serializer_deserializer.html b/2022/12/27/bytecode_serializer_deserializer.html index d574881d..31a318e9 100644 --- a/2022/12/27/bytecode_serializer_deserializer.html +++ b/2022/12/27/bytecode_serializer_deserializer.html @@ -546,21 +546,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/12/28/dockerfile_for_ledge.html b/2022/12/28/dockerfile_for_ledge.html index 6c05bc6d..601f0296 100644 --- a/2022/12/28/dockerfile_for_ledge.html +++ b/2022/12/28/dockerfile_for_ledge.html @@ -273,21 +273,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2022/12/29/torch_dragon.html b/2022/12/29/torch_dragon.html index 2cf45919..936726ef 100644 --- a/2022/12/29/torch_dragon.html +++ b/2022/12/29/torch_dragon.html @@ -189,21 +189,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/01/02/gnu_readline_in_repl.html b/2023/01/02/gnu_readline_in_repl.html index bee7070d..d9146c41 100644 --- a/2023/01/02/gnu_readline_in_repl.html +++ b/2023/01/02/gnu_readline_in_repl.html @@ -343,21 +343,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/01/06/learn_japanese_1.html b/2023/01/06/learn_japanese_1.html index 4cdac2cd..3bf26efc 100644 --- a/2023/01/06/learn_japanese_1.html +++ b/2023/01/06/learn_japanese_1.html @@ -186,21 +186,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/01/07/a_special_call_name_of_hakka.html b/2023/01/07/a_special_call_name_of_hakka.html index 329c84e7..3a722fd7 100644 --- a/2023/01/07/a_special_call_name_of_hakka.html +++ b/2023/01/07/a_special_call_name_of_hakka.html @@ -197,21 +197,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/01/15/Freud_Three_Essays_On_The_Theory_Of_Sexuality.html b/2023/01/15/Freud_Three_Essays_On_The_Theory_Of_Sexuality.html index 5de8105a..37938e89 100644 --- a/2023/01/15/Freud_Three_Essays_On_The_Theory_Of_Sexuality.html +++ b/2023/01/15/Freud_Three_Essays_On_The_Theory_Of_Sexuality.html @@ -229,21 +229,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/01/23/field_under_the_sun.html b/2023/01/23/field_under_the_sun.html index 84296fd8..ded6b3db 100644 --- a/2023/01/23/field_under_the_sun.html +++ b/2023/01/23/field_under_the_sun.html @@ -190,21 +190,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/01/28/learn_japanese_2.html b/2023/01/28/learn_japanese_2.html index dd29a938..c786b7cd 100644 --- a/2023/01/28/learn_japanese_2.html +++ b/2023/01/28/learn_japanese_2.html @@ -505,21 +505,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/01/29/learn_japanese_3.html b/2023/01/29/learn_japanese_3.html index 610d2de1..9b9b2818 100644 --- a/2023/01/29/learn_japanese_3.html +++ b/2023/01/29/learn_japanese_3.html @@ -556,21 +556,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/01/31/protobuf.html b/2023/01/31/protobuf.html index 1b08b921..ad327b8a 100644 --- a/2023/01/31/protobuf.html +++ b/2023/01/31/protobuf.html @@ -476,21 +476,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/02/03/tensorflow_2.html b/2023/02/03/tensorflow_2.html index 7d21c172..05dfa088 100644 --- a/2023/02/03/tensorflow_2.html +++ b/2023/02/03/tensorflow_2.html @@ -492,21 +492,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/03/01/doxygen_work_with_cmake.html b/2023/03/01/doxygen_work_with_cmake.html index 09e955c2..8495494e 100644 --- a/2023/03/01/doxygen_work_with_cmake.html +++ b/2023/03/01/doxygen_work_with_cmake.html @@ -274,21 +274,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/03/03/use_StableDiffusion_gen_photo.html b/2023/03/03/use_StableDiffusion_gen_photo.html index 7623b81b..6f395e27 100644 --- a/2023/03/03/use_StableDiffusion_gen_photo.html +++ b/2023/03/03/use_StableDiffusion_gen_photo.html @@ -371,21 +371,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/03/14/use_StableDiffusion_gen_photo_with_gpu_on_windows.html b/2023/03/14/use_StableDiffusion_gen_photo_with_gpu_on_windows.html index 49f58b77..8fb8b7a7 100644 --- a/2023/03/14/use_StableDiffusion_gen_photo_with_gpu_on_windows.html +++ b/2023/03/14/use_StableDiffusion_gen_photo_with_gpu_on_windows.html @@ -364,21 +364,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/03/15/faceswap_1.html b/2023/03/15/faceswap_1.html index 1cc1e8da..f17d4642 100644 --- a/2023/03/15/faceswap_1.html +++ b/2023/03/15/faceswap_1.html @@ -263,21 +263,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/03/23/learn_japanese_4.html b/2023/03/23/learn_japanese_4.html index 542b092d..bffbf982 100644 --- a/2023/03/23/learn_japanese_4.html +++ b/2023/03/23/learn_japanese_4.html @@ -444,21 +444,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/04/13/yin_keng.html b/2023/04/13/yin_keng.html index a015f4ba..25632e27 100644 --- a/2023/04/13/yin_keng.html +++ b/2023/04/13/yin_keng.html @@ -331,21 +331,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/05/31/hu_bian_de_mo_chou_nv.html b/2023/05/31/hu_bian_de_mo_chou_nv.html index ec599141..abcba84d 100644 --- a/2023/05/31/hu_bian_de_mo_chou_nv.html +++ b/2023/05/31/hu_bian_de_mo_chou_nv.html @@ -189,21 +189,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/2023/07/04/travel_202351.html b/2023/07/04/travel_202351.html index 5ead4adf..e6c3dd65 100644 --- a/2023/07/04/travel_202351.html +++ b/2023/07/04/travel_202351.html @@ -157,7 +157,7 @@

后记

@@ -189,21 +189,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/archive.html b/archive.html index a87b9ec6..aee0b57e 100644 --- a/archive.html +++ b/archive.html @@ -90,7 +90,7 @@
@@ -103,7 +103,7 @@

归档(79)

- +
@@ -121,21 +121,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/calendar.html b/calendar.html index af812a9e..f1aeb2a5 100644 --- a/calendar.html +++ b/calendar.html @@ -118,21 +118,21 @@

微信公众号

最新文章

标签云

时间机器

diff --git a/index.html b/index.html index 3a98f867..14008ab8 100644 --- a/index.html +++ b/index.html @@ -104,6 +104,13 @@

敏行如思,毅往无前!

+

+ 小人革面,君子豹变 + 2023-08-01 Tue +

+
+
+

异乡有悟:五一假期陕北自驾游 2023-07-04 Tue @@ -272,13 +279,6 @@

-

- Ledge语言:字节码编译文件的存储与加载 - 2022-12-28 Wed -

-
-
-
+

+ Ledge语言:字节码编译文件的存储与加载 + 2022-12-28 Wed +

+
+
+

用clang-format统一代码风格 2022-12-20 Tue @@ -272,13 +279,6 @@

-

- C++语言导学(5): 容器 - 2022-10-26 Wed -

-
-
-
+

+ C++语言导学(5): 容器 + 2022-10-26 Wed +

+
+
+

C++语言导学(4): pImpl习惯用法 2022-10-26 Wed @@ -218,21 +225,21 @@

微信公众号

diff --git a/rss.xml b/rss.xml index 9db06e41..a20d1913 100644 --- a/rss.xml +++ b/rss.xml @@ -21,6 +21,17 @@ http://www.lesliezhu.com + + 小人革面,君子豹变 + http://www.lesliezhu.com/2023/08/01/junzibaobian.html + + http://www.lesliezhu.com/2023/08/01/junzibaobian.html + + 2023-08-01 Tue + + http://www.lesliezhu.com/2023/08/01/junzibaobian.html + + 异乡有悟:五一假期陕北自驾游 http://www.lesliezhu.com/2023/07/04/travel_202351.html diff --git a/search.json b/search.json index 5404024b..4814f66c 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"title": "\u5f02\u4e61\u6709\u609f\uff1a\u4e94\u4e00\u5047\u671f\u9655\u5317\u81ea\u9a7e\u6e38", "url": "/2023/07/04/travel_202351.html", "content": "None"}, {"title": "\u6e56\u8fb9\u7684\u83ab\u6101\u5973", "url": "/2023/05/31/hu_bian_de_mo_chou_nv.html", "content": "None"}, {"title": "\u5357\u5317\u671d\u4eba\u7269\u4e4b\u9634\u94ff", "url": "/2023/04/13/yin_keng.html", "content": "None"}, {"title": "\u65e5\u8bed\u5165\u95e8\u9636\u6bb5\u4f8b\u53e5\u6574\u7406", "url": "/2023/03/23/learn_japanese_4.html", "content": "None"}, {"title": "FaceSwap\u8fdb\u884c\u89c6\u9891AI\u6362\u8138", "url": "/2023/03/15/faceswap_1.html", "content": "None"}, {"title": "Windows\u4f7f\u7528Stable Diffusion\u8fdb\u884cAI\u753b\u56fe(GPU)", "url": "/2023/03/14/use_StableDiffusion_gen_photo_with_gpu_on_windows.html", "content": "None"}, {"title": "Mac\u4f7f\u7528Stable Diffusion\u8fdb\u884cAI\u753b\u56fe(CPU)", "url": "/2023/03/03/use_StableDiffusion_gen_photo.html", "content": "None"}, {"title": "CStdString:\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684\u5b57\u7b26\u4e32\u7c7b\u5b9e\u73b0", "url": "/2019/12/29/about_CStdString.html", "content": "None"}, {"title": "CMake\u4f7f\u7528Doxygen\u81ea\u52a8\u751f\u6210\u6587\u6863", "url": "/2023/03/01/doxygen_work_with_cmake.html", "content": "None"}, {"title": "\u4f7f\u7528shred\u5de5\u5177\u5f7b\u5e95\u7c89\u788e\u6587\u4ef6", "url": "/2022/11/12/delete_file_with_shred.html", "content": "None"}, {"title": "\u706b\u628a\u9f99", "url": "/2022/12/29/torch_dragon.html", "content": "None"}, {"title": "TensorFlow\u8bfb\u53d6.pb\u6a21\u578b\u6587\u4ef6\u5e76\u9884\u6d4b\u56fe\u7247", "url": "/2023/02/03/tensorflow_2.html", "content": "None"}, {"title": "\u6e90\u7801\u7f16\u8bd1TensorFlow\u4e3aC++ API\u52a8\u6001\u5e93", "url": "/2019/08/29/tensorflow_1.html", "content": "None"}, {"title": "Protocol Buffers:\u8c37\u6b4c\u5f00\u6e90\u7684\u6570\u636e\u4ea4\u6362\u683c\u5f0f\u534f\u8bae", "url": "/2023/01/31/protobuf.html", "content": "None"}, {"title": "\u5236\u4f5crpm\u5b89\u88c5\u5305\u6587\u4ef6", "url": "/2022/10/24/yum_rpm.html", "content": "
\n

\u5236\u4f5crpm\u5b89\u88c5\u5305\u6587\u4ef6

\n\n
\n

1. \u5236\u4f5crpm\u6587\u4ef6

\n
\n

\n\u8fd9\u91cc\u5047\u8bbe\u6709\u4e00\u4e9b\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u76f8\u5173Shell\u811a\u672c\uff0c\u60f3\u6253\u5305\u4e3arpm\u683c\u5f0f\u5b9e\u73b0\u4e00\u952e\u81ea\u52a8\u5b89\u88c5\u3002\n

\n
    \n
  • \u5b89\u88c5\u5de5\u5177\u5305
  • \n
\n
\n$ sudo yum install rpm-build rpmdevtools\n
\n
    \n
  • \u521b\u5efa\u5de5\u4f5c\u76ee\u5f55
  • \n
\n
\n$ rpmdev-setuptree  # \u9ed8\u8ba4\u521b\u5efa~/rpmbuild/\n\n$ tree ~/rpmbuild/\n\n~/rpmbuild/\n\u251c\u2500\u2500 BUILD\n\u251c\u2500\u2500 BUILDROOT\n\u251c\u2500\u2500 RPMS\n\u251c\u2500\u2500 SOURCES\n\u251c\u2500\u2500 SPECS\n\u2514\u2500\u2500 SRPMS\n
\n

\n\u5982\u679c\u66f4\u6539\u4e00\u4e9b\u9ed8\u8ba4\u8bbe\u7f6e\uff0c\u76f4\u63a5\u4fee\u6539\u6587\u4ef6 ~/.rpmmacros:\n

\n
\n%_topdir %(echo $HOME)/rpmbuild\n\n%_smp_mflags %( \\\n    [ -z \"$RPM_BUILD_NCPUS\" ] \\\\\\\n        && RPM_BUILD_NCPUS=\"`/usr/bin/nproc 2>/dev/null || \\\\\\\n                             /usr/bin/getconf _NPROCESSORS_ONLN`\"; \\\\\\\n    if [ \"$RPM_BUILD_NCPUS\" -gt 16 ]; then \\\\\\\n        echo \"-j16\"; \\\\\\\n    elif [ \"$RPM_BUILD_NCPUS\" -gt 3 ]; then \\\\\\\n        echo \"-j$RPM_BUILD_NCPUS\"; \\\\\\\n    else \\\\\\\n        echo \"-j3\"; \\\\\\\n    fi )\n\n%__arch_install_post \\\n    [ \"%{buildarch}\" = \"noarch\" ] || QA_CHECK_RPATHS=1 ; \\\n    case \"${QA_CHECK_RPATHS:-}\" in [1yY]*) /usr/lib/rpm/check-rpaths ;; esac \\\n    /usr/lib/rpm/check-buildroot\n
\n
\n
\n

1.1. \u51c6\u5907\u8f6f\u4ef6\u6e90\u6587\u4ef6

\n
\n
\n$ tree ~/rpmbuild/SOURCES/\n\n~/rpmbuild/SOURCES/\n\u251c\u2500\u2500 test-1.0.0\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 Makefile\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test.exe\n\u2514\u2500\u2500 test-1.0.0.tar.gz\n
\n

\n\u4e3b\u8981\u6587\u4ef6\u662f ~/rpmbuild/SOURCES/test-1.0.0/Makefile \u89c4\u5b9a\u4e86\u5982\u4f55\u6267\u884c\u5b89\u88c5\u6b65\u9aa4:\n

\n
\n
ifdef DESTDIR\n        destDir=$(DESTDIR)/usr/local/Test/bin\nelse\n        destDir=~/Test/bin\nendif\n\ninstall: test.exe\n        test -d $(destDir) || mkdir -p $(destDir)\n        cp test.exe $(destDir)/test.exe\n\n.PHONY: clean\n\nclean:\n        rm -f $(destDir)/test.exe\n
\n
\n

\n\u4e4b\u540e\u5c06\u8f6f\u4ef6\u6e90\u6587\u4ef6\u76ee\u5f55\u6253\u5305\u4e3a *.tar.gz \u683c\u5f0f\u6587\u4ef6\u3002\n

\n
\n
\n
\n

1.2. \u521b\u5efaSPEC\u6587\u4ef6

\n
\n

\n\u4f7f\u7528 vim \u6253\u5f00 *.spec \u540e\u7f00\u6587\u4ef6\u65f6\u4f1a\u81ea\u52a8\u52a0\u8f7d\u6a21\u677f\uff0c\u6e90\u81ea\u4e8e\u8bfb\u53d6\u4e86\u6a21\u677f\u6587\u4ef6 /usr/share/vim/vimfiles/template.spec.\n

\n

\n\u5982\u679c\u81ea\u5df1\u8981\u6dfb\u52a0\u65b0\u6a21\u677f\u5219:\n

\n
\n$ vim /etc/vimrc\n\nautocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec  # \u81ea\u5e26\u7684\u6a21\u677f\u89c4\u5219\nautocmd BufNewFile *.test 0r /usr/share/vim/vimfiles/template.test  # \u81ea\u5b9a\u4e49\u7684\u65b0\u589e\u6a21\u677f\u89c4\u5219\n
\n

\n~/rpmbuild/SPECS/test.spec \u5185\u5bb9:\n

\n
\n#\n# \u4ee5#\u7b26\u53f7\u5f00\u5934\u7684\u884c\u662f\u6ce8\u91ca\u884c\n# 2022-10-21\n# Author: LeslieZhu\n\n# \u4f1a\u521b\u5efa\u76ee\u5f55: rpmbuild/BUILDROOT/%%(name)-%%(version)-%%(release).%%(arch)\nName:\t test\n\n# \u7248\u672c\u53f7\nVersion: 1.0.0\n\n# \u53d1\u5e03\u6b21\u6570\nRelease: 2\n\nSummary: A Test Program\n\nGroup: TestTeam\n\nLicense: GPLv3\n\n# N/A: \u8868\u793a\u6ca1\u6709\nURL: N/A\n\n# \u6784\u5efa\u76ee\u6807\u67b6\u6784\nBuildArch: x86_64\n\n# \u7528\u6765\u6784\u5efaRPM\u6587\u4ef6\u7684\u6e90\u6587\u4ef6,\u5982\u679c\u4e0d\u63d0\u4f9b\u5219\u4f7f\u7528\u4e0b\u65b9\u7684%files\nSource0: %{name}-%{version}.tar.gz\n\n# \u6784\u5efa\u7684\u65f6\u5019\u4f9d\u8d56\u7684\u8f6f\u4ef6\u5305\nBuildRequires: gcc,vim\n\n# \u8f6f\u4ef6\u8fd0\u884c\u65f6\u9700\u8981\u7684\u8f6f\u4ef6\u5305\nRequires: gcc,vim\n\n%description\n\nThis is a test program.\n\n# \u6d4b\u8bd5\u5b89\u88c5\u76ee\u5f55\nBuildRoot: %_topdir/BUILDROOT\n\n# \u6784\u5efa\u8f6f\u4ef6\u5305\u4e4b\u524d\u8981\u505a\u7684\u4e8b\u60c5\n%prep\n\n# \u89e3\u538b\u5e76cd,\u5c06%_sourcedir\u5185\u5bb9\u89e3\u538b\u5230%_builddir\n%setup -q\n\n\n%build\n# \u5982\u679c\u6709\u6e90\u7801\u7f16\u8bd1\u5219\u4e00\u822c\u662f ./configure %{?_smp_mflags}\n# make %{?_smp_mflags}\n\n%install\n\nmake DESTDIR=%{buildroot} install\n\n\n%pre\n# rpm\u6587\u4ef6\u5b89\u88c5\u524d\necho install start....\n\n%post\n# rpm\u6587\u4ef6\u5b89\u88c5\u540e\necho install done\n\n%preun\n# \u5378\u8f7d\u524d\necho uninstall start...\n\n%postun\n# \u5378\u8f7d\u540e\necho uninstall done\n\n%clean\n# \u6e05\u7406\necho clean start...\nmake DESTDIR=%{buildroot} clean\necho clean done...\n\n\n%files\n\n# /path/to/ \u5982\u679c\u662f\u67d0\u4e2a\u76ee\u5f55\u5219\u76f4\u63a5\u628a\u76ee\u5f55\u5199\u5230\u8fd9\u91cc\u5373\u53ef\n/usr/local/Test/bin/test.exe\n\n%doc\n\n# /path/to/docfile \u6587\u6863\u8def\u5f84\n
\n

\n\u6b64\u65f6\u76ee\u5f55\u7ed3\u6784:\n

\n
\n\u251c\u2500\u2500 BUILD\n\u251c\u2500\u2500 BUILDROOT\n\u251c\u2500\u2500 RPMS\n\u251c\u2500\u2500 SOURCES\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 test-1.0.0\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Makefile\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 test.exe\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test-1.0.0.tar.gz\n\u251c\u2500\u2500 SPECS\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test.spec\n\u2514\u2500\u2500 SRPMS\n
\n
\n
\n
\n

1.3. \u6784\u5efaRPM\u6587\u4ef6

\n
\n
\n$ rpmbuild -ba SPECS/test.spec  # \u4e8c\u8fdb\u5236\u548csrc rpm\u6587\u4ef6\n$ rpmbuild -bb SPECS/test.spec  # \u53ea\u751f\u6210\u4e8c\u8fdb\u5236rpm\u6587\u4ef6\n$ rpmbuild -bs SPECS/test.spec  # \u53ea\u751f\u6210src rpm\u6587\u4ef6\n
\n

\n\u76ee\u5f55\u6587\u4ef6:\n

\n
\n\u251c\u2500\u2500 BUILD\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test-1.0.0\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 debugfiles.list\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 debuglinks.list\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 debugsources.list\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 elfbins.list\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 Makefile\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 test.exe\n\u251c\u2500\u2500 BUILDROOT\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test-1.0.0-2.x86_64\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 usr\n\u2502\u00a0\u00a0         \u2514\u2500\u2500 local\n\u2502\u00a0\u00a0             \u2514\u2500\u2500 Test\n\u2502\u00a0\u00a0                 \u2514\u2500\u2500 bin\n\u251c\u2500\u2500 RPMS\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 x86_64\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 test-1.0.0-2.x86_64.rpm\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 test-debuginfo-1.0.0-2.x86_64.rpm\n\u251c\u2500\u2500 SOURCES\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 test-1.0.0\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Makefile\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 test.exe\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test-1.0.0.tar.gz\n\u251c\u2500\u2500 SPECS\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test.spec\n\u2514\u2500\u2500 SRPMS\n
\n
\n
\n
\n

1.4. \u5b89\u88c5\u8f6f\u4ef6\u5305

\n
\n
\n$ sudo rpm -ivh RPMS/x86_64/test-1.0.0-2.x86_64.rpm\n\nPreparing...                          ################################# [100%]\ninstall start....\nUpdating / installing...\n   1:test-1.0.0-2                     ################################# [100%]\ninstall done\n\n$ ls /usr/local/Test/bin/test.exe\n\n/usr/local/Test/bin/test.exe\n
\n
\n
\n
\n

1.5. \u5378\u8f7d\u8f6f\u4ef6\u5305

\n
\n
\n$ sudo rpm -e test-1.0.0-2\nuninstall start...\nuninstall done\n\n$ ll /usr/local/Test/bin/\ntotal 0\n
\n
\n
\n
\n\n
"}, {"title": "\u6807\u51c6\u65e5\u672c\u8bed\u521d\u7ea7(\u7b2c2\u8bfe):\u3053\u308c\u306f\u672c\u3067\u3059", "url": "/2023/01/29/learn_japanese_3.html", "content": "None"}, {"title": "\u6807\u51c6\u65e5\u672c\u8bed\u521d\u7ea7(\u7b2c1\u8bfe):\u674e\u5148\u751f\u662f\u4e2d\u56fd\u4eba", "url": "/2023/01/28/learn_japanese_2.html", "content": "None"}, {"title": "\u5728\u5e0c\u671b\u7684\u7530\u91ce\u4e0a", "url": "/2023/01/23/field_under_the_sun.html", "content": "None"}, {"title": "\u5f17\u6d1b\u4f0a\u5fb7\u4e0e\u300a\u6027\u5b66\u4e09\u8bba\u300b", "url": "/2023/01/15/Freud_Three_Essays_On_The_Theory_Of_Sexuality.html", "content": "None"}, {"title": "LLVM\u6846\u67b6(1):\u5f00\u7bc7", "url": "/2022/12/17/llvm_1.html", "content": "None"}, {"title": "\u5ba2\u5bb6\u4eba\u7684\u4e00\u79cd\u5c11\u89c1\u201c\u4f2f-\u53d4\u201d\u7c7b\u5173\u7cfb\u79f0\u547c", "url": "/2023/01/07/a_special_call_name_of_hakka.html", "content": "None"}, {"title": "\u5173\u4e8e\u5b66\u65e5\u8bed\u8fd9\u4ef6\u4e8b", "url": "/2023/01/06/learn_japanese_1.html", "content": "None"}, {"title": "\u4f7f\u7528Dockerfile\u548cCMake\u7f16\u8bd1LLVM\u7a0b\u5e8f", "url": "/2022/12/28/dockerfile_for_ledge.html", "content": "None"}, {"title": "\u7528readline\u5e93\u6539\u8fdbREPL\u4ea4\u4e92\u4f53\u9a8c", "url": "/2023/01/02/gnu_readline_in_repl.html", "content": "None"}, {"title": "Ledge\u8bed\u8a00\uff1a\u5b57\u8282\u7801\u7f16\u8bd1\u6587\u4ef6\u7684\u5b58\u50a8\u4e0e\u52a0\u8f7d", "url": "/2022/12/27/bytecode_serializer_deserializer.html", "content": "None"}, {"title": "\u7528clang-format\u7edf\u4e00\u4ee3\u7801\u98ce\u683c", "url": "/2022/12/19/git_clang_format.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u7f16\u8bd1\u5668(12):\u7ed3\u8bed", "url": "/2022/12/16/writing_an_interpreter_in_cpp_12.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u7f16\u8bd1\u5668(11):\u95ed\u5305", "url": "/2022/12/16/writing_an_interpreter_in_cpp_11.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u7f16\u8bd1\u5668(10):\u5185\u7f6e\u51fd\u6570", "url": "/2022/12/16/writing_an_interpreter_in_cpp_10.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u7f16\u8bd1\u5668(9):\u51fd\u6570\u4e0e\u6808\u5e27", "url": "/2022/12/13/writing_an_interpreter_in_cpp_9.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u7f16\u8bd1\u5668(8):\u7b26\u53f7\u8868\u3001\u5b57\u7b26\u4e32\u3001\u6570\u7ec4\u4e0e\u5b57\u5178", "url": "/2022/12/12/writing_an_interpreter_in_cpp_8.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u7f16\u8bd1\u5668(7):\u8df3\u8f6c\u6307\u4ee4", "url": "/2022/12/12/writing_an_interpreter_in_cpp_7.html", "content": "None"}, {"title": "\u660e\u5929\u505a\u5ba2\u8981\u65af\u6587", "url": "/2022/12/11/be_a_guest_tomorrow.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u7f16\u8bd1\u5668(6):\u5b57\u8282\u7801\u4e0e\u865a\u62df\u673a", "url": "/2022/11/26/writing_an_interpreter_in_cpp_6.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u89e3\u91ca\u5668(5):\u529f\u80fd\u6269\u5c55", "url": "/2022/11/24/writing_an_interpreter_in_cpp_5.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u89e3\u91ca\u5668(4):\u6c42\u503c", "url": "/2022/11/21/writing_an_interpreter_in_cpp_4.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u89e3\u91ca\u5668(3):\u8bed\u6cd5\u5206\u6790\u4e0e\u666e\u62c9\u7279\u89e3\u6790", "url": "/2022/11/13/writing_an_interpreter_in_cpp_3.html", "content": "None"}, {"title": "Docker\u955c\u50cf\u91cc\u4e3a\u4ec0\u4e48Linux\u65e0\u6cd5\u5b89\u88c5Man Pages\uff1f", "url": "/2022/11/21/man_pages_missing.html", "content": "None"}, {"title": "Linux\u5982\u4f55\u901a\u8fc7PAM\u7ba1\u7406\u6388\u6743?", "url": "/2022/11/21/PAM_in_linux.html", "content": "None"}, {"title": "Linux\u5982\u4f55\u8bbe\u7f6e\u7528\u6237\u957f\u65f6\u95f4\u4e0d\u64cd\u4f5c\u5c31\u81ea\u52a8\u767b\u51fa?", "url": "/2022/11/20/TMOUT_env_variable_in_liunux.html", "content": "None"}, {"title": "Git\u5982\u4f55\u7ba1\u7406\u5b50\u6a21\u5757\u548c\u7b2c\u4e09\u65b9\u6a21\u5757\uff1f", "url": "/2022/11/17/git_subtree_and_submodule.html", "content": "None"}, {"title": "C++\u7591\u96be\u6742\u75c7(1):\u5c0f\u5fc3std::variant\u4e2d\u7684bool\u7c7b\u578b\u503c", "url": "/2022/11/16/cpp_go_to_wrong_1.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u89e3\u91ca\u5668(2):\u8bcd\u6cd5\u5206\u6790", "url": "/2022/11/11/writing_an_interpreter_in_cpp_2.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u89e3\u91ca\u5668(1):\u5f00\u7bc7", "url": "/2022/11/10/writing_an_interpreter_in_cpp_1.html", "content": "None"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(10):\u5e76\u53d1(\u4e0b)", "url": "/2022/11/04/cpp_10.html", "content": "None"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(9):\u5e76\u53d1(\u4e0a)", "url": "/2022/11/01/cpp_9.html", "content": "None"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(8):\u6a21\u677f", "url": "/2022/11/01/cpp_8.html", "content": "None"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(7):\u51fd\u6570\u5bf9\u8c61(Function Object)", "url": "/2022/10/31/cpp_7.html", "content": "None"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(6): lambda\u8868\u8fbe\u5f0f", "url": "/2022/10/26/cpp_6.html", "content": "
\n

C++\u8bed\u8a00\u5bfc\u5b66(6): lambda\u8868\u8fbe\u5f0f

\n\n
\n

1. \u5f15\u8a00

\n
\n

\nlambda\u8868\u8fbe\u5f0f\u662f\u4e00\u4e2a\u53ef\u6267\u884c\u7684\u4ee3\u7801\u5355\u5143\uff0c\u53ef\u4ee5\u770b\u4f5c\u662f\u4e00\u4e2a\u533f\u540d\u5185\u8054(inline)\u51fd\u6570\uff0c\u4e0b\u9762\u4ee5\u533f\u540d\u51fd\u6570\u4ee3\u6307lambda\u8868\u8fbe\u5f0f\u3002\n

\n

\n\u5b9a\u4e49\u8bed\u6cd5:\n

\n
\n
[capture list] (parameter list) -> return type { function body }\n
\n
\n

\n\u533f\u540d\u51fd\u6570\u7684\u51fd\u6570\u4f53\u4e00\u822c\u64cd\u4f5c\u6bd4\u8f83\u5c11\uff0c\u800c\u4e14\u533f\u540d\u51fd\u6570\u4e00\u822c\u4e0d\u4f1a\u53cd\u590d\u5728\u591a\u5904\u4f7f\u7528\uff0c\u5e38\u662f\u4e00\u6b21\u6027\u7684\u3002\n

\n
\n
\n
\n

2. \u53c2\u6570\u5217\u8868

\n
\n

\n\u6bd4\u5982:\n

\n
\n
auto f = [] { return 42; }\n\nauto f = []() { return 42; } // \u7b49\u6548\n
\n
\n

\n\u8fd9\u4e2a\u51fd\u6570\u6ca1\u6709\u6307\u5b9a\u53c2\u6570\u5c31\u662f\u6ca1\u6709\u53c2\u6570\uff0c\u4e5f\u6ca1\u6709\u6307\u5b9a\u8fd4\u56de\u503c\u7c7b\u578b\uff0c\u5219\u6839\u636e\u6267\u884c\u8bed\u53e5\u5757\u91cc\u9762\u8fd4\u56de\u7684\u7c7b\u578b\u4f5c\u4e3a\u533f\u540d\u51fd\u6570\u7684\u8fd4\u56de\u7c7b\u578b\u3002\n

\n

\n\u6bd4\u5982:\n

\n
\n
auto f = [](const string& a, cosnt string&b) { return a.size() + b.size(); }\n
\n
\n

\nlambda\u8868\u8fbe\u5f0f\u5b9a\u4e49\u7684\u51fd\u6570\u53c2\u6570\u6ca1\u6709\u9ed8\u8ba4\u503c\uff0c\u610f\u5473\u7740\u6bcf\u6b21\u5fc5\u987b\u63d0\u4f9b\u548c\u5b9a\u4e49\u4e00\u6837\u591a\u7684\u5b9e\u53c2\u3002\n

\n
\n
\n
\n

3. \u6355\u83b7\u5217\u8868

\n
\n

\n\u6bd4\u5982:\n

\n
\n
int sz1 = 1024;\nint sz2 = 2048;\n\nauto f = [sz1,sz2](const string& a) { return a.size() >= sz1 && a.size() <= sz2; }\nauto wc = find_if(words.begin(), words.end(), [sz](const string &a) { return a.size() >= sz; });\n
\n
\n

\n\u8fd9\u91cc\u7684sz\u662f\u672c\u5730\u53d8\u91cf\uff0c\u5982\u679c\u8981\u8ba9\u533f\u540d\u51fd\u6570\u53ef\u4ee5\u4f7f\u7528\u672c\u5730\u53d8\u91cf\uff0c\u5219\u9700\u8981\u5728\u4e2d\u62ec\u53f7(\u6355\u83b7\u5217\u8868)\u91cc\u9762\u63d0\u4f9b\u3002\n

\n

\n\u6bd4\u5982:\n

\n
\n
for_each(wc, words.end(), [](const string& s) { cout << s << \" \"; };\n
\n
\n

\n\u533f\u540d\u51fd\u6570\u53ef\u4ee5\u4f7f\u7528cout\uff0c\u867d\u7136cout\u5e76\u6ca1\u6709\u5199\u5230\u6355\u83b7\u5217\u8868\u4e2d\u3002\n

\n

\n\u56e0\u4e3a\u533f\u540d\u51fd\u6570\u5b9a\u4e49\u65f6\u7684\u4e2d\u62ec\u53f7\u6355\u83b7\u5217\u8868\u91cc\u9762\u53ea\u7528\u4e8e\u5199\u672c\u5730\u975e\u9759\u6001\u53d8\u91cf\uff0c\u5982\u679c\u662f\u6240\u5728\u51fd\u6570\u4e4b\u5916\u7684\u5219\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u3002\n

\n

\n\u5c40\u90e8\u53d8\u91cf\u8fdb\u5165\u533f\u540d\u51fd\u6570\u4f7f\u7528\u4f20\u503c\u6216\u5f15\u7528\uff0c\u6bd4\u5982:\n

\n
\n
void fnc1()\n{\n    size_t v1 = 42;    // local variable\n    auto f = [v1] { return v1; }; // copy v1 into f\n\n    v1 = 0;\n    auto j = f(); // j=42, not 0\n}\n\nvoid func2()\n{\n    size v1 = 42; // local variable\n    auto f2 = [&v1] { return v1; };\n\n    v1 = 0;\n    auto j = f2(); // j=0, not 42\n}\n
\n
\n

\n\u5f53\u4f7f\u7528\u5f15\u7528\u4f20\u9012\u65f6\uff0c\u8981\u6ce8\u610f\u5c40\u90e8\u53d8\u91cf\u79bb\u5f00\u4f5c\u7528\u57df\u5c31\u9500\u6bc1\u4e86\uff0c\u56e0\u6b64\u8981\u6ce8\u610f\u533f\u540d\u51fd\u6570\u6267\u884c\u65f6\u6240\u6355\u83b7\u7684\u53d8\u91cf\u662f\u5426\u8fd8\u6709\u6548\u3002\n

\n

\n\u4f20\u9012\u53d8\u91cf\u8fd8\u53ef\u4ee5\u4f7f\u7528\u7b80\u5199\u65b9\u5f0f:\n

\n
\n
auto f = [] { return v1; }; // \u4e0d\u6355\u83b7\nauto f = [=] { return v1; }; // \u81ea\u52a8\u4ee5\u4f20\u503c\u5f62\u5f0f\u6355\u83b7\u53d8\u91cf\nauto f = [&] { return v1; }; // \u81ea\u52a8\u4ee5\u5f15\u7528\u5f62\u5f0f\u6355\u83b7\u53d8\u91cf\n\nauto f = [&,c] { return v1 > c; }; // \u9664\u4e86\u53d8\u91cfc\uff0c\u5176\u4f59\u81ea\u52a8\u5f15\u7528\u4f20\u9012\u6355\u83b7\u53d8\u91cf\nauto f = [=,&c] { return v1 > c; }; // \u9664\u4e86c\uff0c\u5176\u4f59\u81ea\u52a8\u4f20\u503c\u4f20\u9012\u6355\u83b7\u53d8\u91cf\n
\n
\n

\n\u6355\u83b7\u7684\u53d8\u91cf\u662f\u5426\u53ef\u4ee5\u5728\u533f\u540d\u51fd\u6570\u5185\u90e8\u88ab\u6539\u53d8\uff1f\n

\n

\n\u6bd4\u5982:\n

\n
\n
void fcn3()\n{\n    size_t v1 = 42;\n    auto f1 = [v1] { return ++v1; }; // error: \u4f20\u503c\u5f62\u5f0f\u4e0d\u80fd\u6539\u53d8\u6355\u83b7\u53d8\u91cf\u7684\u503c\n    auto f2 = [v1]() mutable { return ++v1; }; // right: \u4f7f\u7528\u4e86mutable\u6807\u8bb0\n    v1 = 0;\n    auto j = f2(); // j = 43\n}\n\nvoid fcn()\n{\n    size_t v1 = 42;\n    const size_t v2 = 42;\n\n    auto f1 = [&v1] { return ++v1; } // right\n    auto f2 = [&v2] { return ++v2; } // error: v2 is const\n\n    v1 = 0;\n    auto j = f1(); // j = 1\n}\n
\n
\n

\n\u4e00\u822c\u662f\u4e0d\u5728\u533f\u540d\u51fd\u6570\u5185\u90e8\u6539\u53d8\u6355\u83b7\u7684\u53d8\u91cf\u7684\u3002\n

\n
\n
\n
\n

4. \u8fd4\u56de\u503c

\n
\n

\n\u5982\u679c\u533f\u540d\u51fd\u6570\u4f53\u53ea\u6709\u4e00\u6761return\u8bed\u53e5\uff0c\u90a3\u4e48\u6700\u7ec8\u533f\u540d\u51fd\u6570\u7684\u8fd4\u56de\u7c7b\u578b\u7531\u8fd9\u4e2areturn\u8bed\u53e5\u51b3\u5b9a:\n

\n
\n
transform(vi.begin(), vi.end(), vi.begin(), \n                                [](int i){ return i < 0 ? -1 : i; });\n
\n
\n

\n\u5982\u679c\u533f\u540d\u51fd\u6570\u4f53\u6709\u591a\u6761return\u8bed\u53e5\uff0c\u90a3\u4e48\u6700\u7ec8\u533f\u540d\u51fd\u6570\u7684\u8fd4\u56de\u5217\u5e2d\u662fvoid:\n

\n
\n
transform(vi.begin(), vi.end(), vi.begin(), \n                                [](int i){ if(i < 0) return -i; else return i; });\n
\n
\n

\n\u5982\u679c\u533f\u540d\u51fd\u6570\u6307\u5b9a\u4e86\u8fd4\u56de\u7c7b\u578b\uff0c\u5219\u4f7f\u7528\u6b64\u8fd4\u56de\u7c7b\u578b:\n

\n
\n
transform(vi.begin(), vi.end(), vi.begin(), \n                                [](int i) -> int \n                                { if(i < 0) return -i; else return i; });\n
\n
\n
\n
\n
"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(5): \u5bb9\u5668", "url": "/2022/10/26/cpp_5.html", "content": "
\n

C++\u8bed\u8a00\u5bfc\u5b66(5): \u5bb9\u5668

\n\n
\n

1. \u5f15\u8a00

\n
\n

\n\u5982\u679c\u4e00\u4e2a\u7c7b\u7684\u4e3b\u8981\u76ee\u7684\u662f\u4fdd\u5b58\u5bf9\u8c61\uff0c\u90a3\u4e48\u901a\u5e38\u79f0\u4e4b\u4e3a\u5bb9\u5668(container)\u3002\n

\n

\n\u8fd9\u91cc\u4e3b\u8981\u7b80\u5355\u6982\u8ff0\u4e00\u4e0b\u8fd9\u4e9b\u6807\u51c6\u5e93\u5bb9\u5668:\n

\n
    \n
  • vector: \u6709\u5e8f\u5e8f\u5217
  • \n
  • list: \u53cc\u5411\u94fe\u8868
  • \n
  • map: \u5173\u8054\u5b57\u5178
  • \n
  • unordered_map: \u65e0\u5e8f\u54c8\u5e0c
  • \n
\n
\n
\n
\n

2. vector

\n
\n

\n\u4e00\u4e2avector\u5c31\u662f\u4e00\u4e2a\u7ed9\u5b9a\u7c7b\u578b\u5143\u7d20\u7684\u5e8f\u5217\uff0c\u5143\u7d20\u5728\u5185\u5b58\u4e2d\u662f\u8fde\u7eed\u5b58\u50a8\u7684\u3002\n

\n

\n\u5bf9\u4e8evector\u6700\u4e3b\u8981\u7684\u64cd\u4f5c\u662fpush_back()\u8ffd\u52a0\u5185\u5bb9\uff0c\u4f46\u5bb9\u91cf\u4e0d\u8db3\u7684\u65f6\u5019\u5b83\u4f1a\u81ea\u52a8\u6269\u5145\u5bb9\u91cf\uff0c\u5b83\u6709\u4e00\u5957\u81ea\u5df1\u7684\u7b56\u7565\u6765\u6269\u5145\u5bb9\u5668\uff0c\u6548\u7387\u5f88\u9ad8\u3002\n

\n

\nvector\u8db3\u591f\u7075\u6d3b\u3001\u9ad8\u6548\uff0c\u5e94\u8be5\u4f5c\u4e3a\u9ed8\u8ba4\u5bb9\u5668\uff1b\u5c3d\u91cf\u907f\u514d\u5bb9\u5668\u7684\u62f7\u8d1d\u590d\u5236\uff0c\u800c\u662f\u4f7f\u7528\u5f15\u7528\u6216\u6307\u9488\u6765\u907f\u514d\u8fd9\u79cd\u8017\u65f6\u64cd\u4f5c\u3002\n

\n

\n\u4f46vector\u4e3a\u4e86\u4fdd\u8bc1\u9ad8\u6548\u4ee5\u5e94\u7528\u5230\u6027\u80fd\u5173\u952e\u7684\u7a0b\u5e8f\u4e2d\uff0c\u4e0d\u4f1a\u8fdb\u884c\u4e0b\u6807\u8d8a\u754c\u68c0\u67e5\uff0c\u6bd4\u5982:\n

\n
\n
#include <iostream>\n#include <vector>\nusing namespace std;\n\nint main(){\n    try{\n        vector<int> vData;\n\n        //int i = vData[vData.size()];\n        int i = vData.at(vData.size()); // \u63a8\u8350\u4f7f\u7528at()\u65b9\u6cd5\u800c\u4e0d\u662f\u4e0b\u6807\u8bbf\u95ee\n\n    } catch(out_of_range& err){\n      cerr << \"range error\\n\";\n    } catch(...){\n      cerr << \"unknow exception\\n\";\n    }\n\n    return 0;\n}\n
\n
\n
\n
\n
\n

3. list

\n
\n

\n\u5982\u679c\u5e0c\u671b\u5728\u4e00\u4e2a\u5e8f\u5217\u4e2d\u6dfb\u52a0\u3001\u5220\u9664\u5143\u7d20\u800c\u4e0d\u9700\u8981\u79fb\u52a8\u5176\u4ed6\u5143\u7d20\uff0c\u5219\u9009\u62e9list\uff0c\u5b83\u662f\u53cc\u5411\u94fe\u8868\u3002\n

\n
\n
#include <iostream>\n#include <list>\n#include <algorithm>\n\nusing namespace std;\n\nvoid display(const list<int>& data){\n    for(auto &x:data)\n        cout << x << \",\";\n    cout << \"\\n\";\n}\n\nint main()\n{\n    list<int> lData{10,2,3,5,8,1};\n    display(lData); // 10,2,3,5,8,1,\n\n    auto p = find(lData.begin(), lData.end(),3);\n    auto q = find(lData.begin(), lData.end(),8);\n\n    lData.insert(p,12); // \u5728\u8fed\u4ee3\u5668p\u524d\u9762\u63d2\u5165\u503c\n    display(lData); // 10,2,12,3,5,8,1,\n\n    lData.erase(p); // \u9500\u6bc1\u5143\u7d20\n    display(lData); // 10,2,12,5,8,1,\n\n    lData.erase(q); // p,q\u5e76\u6ca1\u6709\u56e0\u4e3a\u524d\u9762insert\u64cd\u4f5c\u800c\u5931\u6548\n    display(lData); // 10,2,12,5,1,\n\n    return 0;\n}\n
\n
\n

\n\u5f53\u6570\u636e\u91cf\u8f83\u5c0f\u65f6\uff0cvector\u6027\u80fd\u4f1a\u4f18\u4e8elist\uff0c\u9664\u975e\u6709\u7406\u7531\u9009\u62e9list\uff0c\u5426\u5219\u5e94\u8be5\u4f7f\u7528vector\u3002\n

\n

\nvector\u65e0\u8bba\u5728\u904d\u5386(find,count)\u6027\u80fd\u8fd8\u662f\u6392\u5e8f\u548c\u641c\u7d22(sort,equal_range)\u6027\u80fd\u90fd\u4f18\u4e8elist\u3002\n

\n
\n
\n
\n

4. map

\n
\n

\nmap\u53c8\u53eb\u5173\u8054\u6570\u7ec4\u6216\u5b57\u5178\uff0c\u7528\u5e73\u8861\u4e8c\u53c9\u6811(\u7ea2\u9ed1\u6811)\u5b9e\u73b0\u3002\n

\n
\n
map<string, int> mData{{\"David\",123},{\"Tom\",123}};// David->123;Tom->123;\n\nmData[\"Leslie\"] = 578; // David->123;Leslie->578;Tom->123;\n\nmData[\"Zhu\"]; // David->123;Leslie->578;Tom->123;Zhu->0;\n
\n
\n

\n\u8fdb\u884c\u4e0b\u6807\u64cd\u4f5c\u672c\u8d28\u662f\u8fdb\u884c\u4e00\u6b21\u641c\u7d22\uff0c\u5982\u679c\u6ca1\u627e\u5230key\u5c31\u81ea\u52a8\u63d2\u5165\u65b0\u5143\u7d20\uff0cvalue\u662f\u5bf9\u5e94\u7684\u9ed8\u8ba4\u503c\u3002\n

\n

\n\u4e00\u822c\u5e38\u7528\u64cd\u4f5c\u662ffind()\u548cinsert()\u3002\n

\n
\n
\n
\n

5. unordered_map

\n
\n

\n\u6807\u51c6\u5e93\u4e2d\u54c8\u5e0c\u5bb9\u5668\u88ab\u53eb\u505a\u201c\u65e0\u5e8f\u201d\u5bb9\u5668\u3002\n

\n

\nunderorder_map\u7684\u64cd\u4f5c\u548cmap\u6ca1\u592a\u5927\u533a\u522b\uff0c\u533a\u522b\u5728\u4e8e\u4e0d\u662f\u7528\u4e00\u4e2a\u6709\u5e8f\u51fd\u6570\u8fdb\u884c\u6bd4\u8f83\u64cd\u4f5c\uff0c\u800c\u662f\u4f7f\u7528\u54c8\u5e0c\u51fd\u6570\u3002\n

\n

\n\u6bd4\u5982:\n

\n
\n
#include <iostream>\n#include <unordered_map>\n\nusing namespace std;\n\nstruct Record{\n   friend struct RHash;\n\n   string name;\n   int age;\n\n   Record(const string& s, const int& i): name(s), age(i){}\n\n   bool operator==(const Record& rhs) const {\n       return name == rhs.name && age == rhs.age;\n   }\n};\n\nstruct RHash{\n    size_t operator()(const Record& r) const {\n        return hash<string>()(r.name)^hash<int>()(r.age);\n    }\n};\n\nvoid display(const unordered_map<Record,int,RHash>& data){\n    cout << \"unordered map: \";\n    for(auto &x:data)\n       cout << \"(\"<<x.first.name<<\",\"<<x.first.age<<\")\" << \"->\" << x.second << \";\";\n    cout << \"\\n\";\n}\n\nint main()\n{\n    unordered_map<Record,int,RHash> uData{{{\"David\",26},123}}; // \u4f7f\u7528\u81ea\u5b9a\u4e49\u54c8\u5e0c\u51fd\u6570\n    display(uData); // (David,26)->123;\n\n    uData[Record(\"Tom\",30)] = 456;\n    display(uData); // (Tom,30)->456;(David,26)->123;\n\n    uData[Record(\"Leslie\",35)] = 578;\n    display(uData); // (Leslie,35)->578;(Tom,30)->456;(David,26)->123;\n\n    uData[Record(\"Zhu\",40)];\n    display(uData); // (Zhu,40)->0;(Leslie,35)->578;(Tom,30)->456;(David,26)->123;\n\n    return 0;\n}\n
\n
\n
\n
\n
"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(4): pImpl\u4e60\u60ef\u7528\u6cd5", "url": "/2022/10/26/cpp_4.html", "content": "
\n

C++\u8bed\u8a00\u5bfc\u5b66(4): pImpl\u4e60\u60ef\u7528\u6cd5

\n
\n

\n\u6761\u6b3e31: \u5c06\u6587\u4ef6\u95f4\u7684\u7f16\u8bd1\u4f9d\u5b58\u5173\u7cfb\u964d\u5230\u6700\u4f4e\u3002 \u2014 \u300aEffective C++\u300b\n

\n

\n\u6761\u6b3e22: \u4f7f\u7528pImpl\u4e60\u60ef\u7528\u6cd5\u65f6\uff0c\u5c06\u7279\u6b8a\u6210\u5458\u51fd\u6570\u7684\u5b9a\u4e49\u653e\u5230\u5b9e\u73b0\u6587\u4ef6\u4e2d\u3002 \u2014 \u300aEffective Modern C++\u300b\n

\n
\n

\npImpl\u4e60\u60ef\u7528\u6cd5\uff0c\u5373pointer to implementation\uff0c\u6307\u7684\u662f\u4ee5\u6307\u9488\u7684\u65b9\u5f0f\u8bbf\u95ee\u7c7b\u7684\u5b9e\u73b0\u90e8\u5206\u3002\n

\n

\n\u6bd4\u5982:\n

\n
\n
class Widget {\npublic:\n    Widget();\n    //...\nprivate:\n    std::string name;\n    std::vector<double> data;\n};\n
\n
\n

\n\u5728\u8fd9\u4e2a\u7c7b\u5b9a\u4e49\u4e2d\uff0c\u56e0\u4e3a\u6570\u636e\u6210\u5458\u7684\u7f18\u6545\uff0c\u8fd9\u4e2a\u5934\u6587\u4ef6\u91cc\u9762\u9700\u8981\u5305\u542bstring,vector\u7b49\uff0c\u8fdb\u800c\u5bfc\u81f4\u51e1\u662f\u4f7f\u7528\u4e86\u8fd9\u4e2a\u7c7b\u7684\u5730\u65b9\u90fd\u4f1a\u9700\u8981\u7f16\u8bd1\u4e00\u6b21\u3002\n

\n

\n\u8fd9\u4e0d\u4f46\u63d0\u9ad8\u4e86\u6574\u4f53\u7684\u7f16\u8bd1\u65f6\u95f4\uff0c\u800c\u4e14\u56e0\u4e3a\u4f9d\u8d56\u95ee\u9898\u4e00\u65e6\u6709\u4efb\u4f55\u6539\u53d8\u90fd\u9700\u8981\u91cd\u65b0\u7f16\u8bd1\u4e00\u6b21\u3002\n

\n

\npImpl\u4e60\u60ef\u7528\u6cd5\u53ef\u4ee5\u964d\u4f4e\u4f9d\u8d56\u4ee5\u63d0\u5347\u7f16\u8bd1\u901f\u5ea6\uff0c\u5982:\n

\n
\n
// Widget.hpp\n\nclass Widget{\npublic:\n    Widget();\n    ~Widget();\n    //...\nprivate:\n    struct Impl;  // \u7528\u4e00\u4e2a\u7ed3\u6784\u4f53\u6765\u5b58\u50a8\u5b9e\u73b0\u90e8\u5206\n    Impl *pImpl;  // \u7528\u4e00\u4e2a\u6307\u9488\u6765\u8bbf\u95ee\u5b9e\u73b0\u90e8\u5206\n};\n
\n
\n

\nWidget::Impl\u662f\u4e00\u4e2a\u5185\u90e8\u7684\u975e\u5b8c\u6574\u7c7b\u578b\uff0c\u800c\u8fd9\u91cc\u7684\u6280\u5de7\u5c31\u5728\u4e8e\u7528\u4e00\u4e2a\u6307\u9488\u6765\u6307\u5411\u5b83\uff0c\u4ece\u800c\u4e0d\u9700\u8981\u5305\u542bstring\u7b49\u5934\u6587\u4ef6\uff0c\u4e5f\u4e0d\u4f1a\u56e0\u4e3a\u4f9d\u8d56\u95ee\u9898\u5bfc\u81f4\u8ddf\u968f\u7740\u91cd\u65b0\u7f16\u8bd1\u3002\n

\n

\n\u5728\u5b9e\u73b0\u90e8\u5206\u6765\u5904\u7406\u7c7b\u7684\u6210\u5458:\n

\n
\n
// Widget.cpp\n\nstruct Widget::Impl\n{\n    std::string name;\n    std::vector<double> data;\n};\n\nWidget()\n: pImpl(new Impl)\n{\n}\n\n~Widget()\n{\n    delete pImpl;\n}\n\n// main.cpp\n\n#include \"Widget.hpp\"\n\nint main()\n{\n    Widget w;\n    return 0;\n}\n
\n
\n

\n\u4f46\u6211\u4eec\u60f3\u4f7f\u7528\u667a\u80fd\u6307\u9488\u6765\u5904\u7406\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u4f7f\u7528\u201c\u88f8\u201d\u6307\u9488\uff0c\u4e5f\u4e0d\u60f3\u51fa\u73b0new\u548cdelete\u8bed\u53e5:\n

\n
\n
// Widget.hpp\n\n#include <memory>\n\nclass Widget {\npublic:\n    Widget();\nprivate:\n    struct Impl;\n    std::unique_ptr<Impl> pImpl;\n};\n\n// Widget.cpp\n\n#include \"Widget.hpp\"\n\n#include <string>\n#include <vector>\n\nstruct Widget::Impl\n{\n    std::string name;\n    std::vector<double> data;\n};\n\nWidget::Widget()\n: pImpl(std::make_unique<Impl>())\n{\n}\n
\n
\n

\n\u4f46\u56e0\u4e3a\u4f7f\u7528\u4e86unique_ptr\u667a\u80fd\u6307\u9488\uff0c\u5b83\u4f1a\u56e0\u4e3aImpl\u5728\u5934\u6587\u4ef6\u4e2d\u662f\u4e00\u4e2a\u975e\u5b8c\u6574\u7c7b\u578b\u800c\u62a5\u9519\uff0c\u539f\u56e0\u662f\u7f16\u8bd1\u5668\u81ea\u52a8\u4ea7\u751f\u7684\u4e00\u4e9b\u9ed8\u8ba4\u4ee3\u7801\u65f6\u8fd8\u4e0d\u77e5\u9053Impl\u7684\u5b8c\u6574\u5b9a\u4e49\uff0c\u9700\u8981\u505a\u4e9b\u6539\u52a8:\n

\n
\n
// Widget.hpp\n\n#include <memory>\n\nclass Widget {\npublic:\n    Widget();\n    ~Widget(); // \u4e0d\u4f7f\u7528\u7f16\u8bd1\u5668\u81ea\u52a8\u751f\u6210\u7684\u6790\u6784\u51fd\u6570\nprivate:\n    struct Impl;\n    std::unique_ptr<Impl> pImpl;\n};\n\n// Widget.cpp\n#include \"Widget.hpp\"\n\n#include <string>\n#include <vector>\n\nstruct Widget::Impl\n{\n    std::string name;\n    std::vector<double> data;\n};\n\nWidget::Widget()\n: pImpl(std::make_unique<Impl>())\n{\n}\n\nWidget::~Widget() = default;   // \u8fd8\u662f\u4f7f\u7528\u7f16\u8bd1\u81ea\u52a8\u4ea7\u751f\u7684\u9ed8\u8ba4\u6790\u6784\u51fd\u6570\uff0c\u4f46\u6b64\u65f6\u5df2\u7ecf\u77e5\u9053Impl\u7684\u5b8c\u6574\u5b9a\u4e49\u4e86\u3002\n
\n
\n

\n\u8fd9\u6837\u5c31\u53ef\u4ee5\u987a\u5229\u7f16\u8bd1\u4e86\u3002\n

\n

\n\u4f46\u56e0\u4e3aunique_ptr\u8981\u6c42\u7c7b\u578b\u662f\u5b8c\u6574\u7c7b\u578b\uff0c\u76f8\u5e94\u7684\u9700\u8981\u628a\u4e00\u4e9b\u7279\u6b8a\u51fd\u6570\u8fdb\u884c\u58f0\u660e\u548c\u5b9e\u73b0\uff0c\u8fd9\u6837\u624d\u80fd\u6b63\u786e\u6267\u884c\u79fb\u52a8\u3001\u590d\u5236\u7b49\u64cd\u4f5c:\n

\n
\n
// Widget.hpp\n\n#include <memory>\n\nclass Widget {\npublic:\n    Widget();\n    ~Widget();   // \u6790\u6784\u51fd\u6570\n\n    Widget(Widget&& rhs);  // \u79fb\u52a8\u6784\u9020\u51fd\u6570\n    Widget& operator=(Widget&& rhs); // \u79fb\u52a8\u590d\u5236\u8fd0\u7b97\u7b26\n\n    Widget(const Widget& rhs);   // \u590d\u5236\u6784\u9020\u51fd\u6570 \n    Widget& operator=(const Widget& rhs); // \u590d\u5236\u8d4b\u503c\u8fd0\u7b97\u7b26\n\nprivate:\n    struct Impl;\n    std::unique_ptr<Impl> pImpl;\n};\n\n// Widget.cpp\n\n#include \"Widget.hpp\"\n\n#include <string>\n#include <vector>\n\nstruct Widget::Impl\n{\n    std::string name;\n    std::vector<double> data;\n};\n\nWidget::Widget()\n: pImpl(std::make_unique<Impl>())\n{\n}\n\nWidget::~Widget() = default;\n\nWidget::Widget(Widget&& rhs) = default;\nWidget& Widget::operator=(Widget&& rhs) = default;\n\nWidget::Widget(const Widget& rhs)\n: pImpl(std::make_unique<Impl>(*rhs.pImpl))\n{\n}\n\nWidget& Widget::operator=(const Widget& rhs)\n{\n   *pImpl = *rhs.pImpl;\n   return *this;\n}\n
\n
\n

\n\u6d4b\u8bd5:\n

\n
\n
// main.cpp\n\n#include \"Widget.hpp\"\n\nint main()\n{\n    Widget w;\n\n    Widget w1(w);\n    Widget w2 = w;\n\n    auto w3(std::move(w));\n    auto w4 = std::move(w3);\n\n    return 0;\n}\n
\n
\n

\n\u57fa\u672c\u4e0a\u5728\u91c7\u7528pImpl\u4e60\u60ef\u7528\u6cd5\u65f6\uff0c\u9996\u9009\u4f7f\u7528unique_ptr\u667a\u80fd\u6307\u9488\uff0c\u8fdb\u800c\u5fc5\u987b\u5b9e\u73b0\u7c7b\u7684\u4e94\u4e2a\u7279\u6b8a\u51fd\u6570:\n

\n
    \n
  • \u6790\u6784\u51fd\u6570
  • \n
  • \u79fb\u52a8\u6784\u9020\u51fd\u6570
  • \n
  • \u79fb\u52a8\u8d4b\u503c\u8fd0\u7b97\u7b26
  • \n
  • \u590d\u5236\u6784\u9020\u51fd\u6570
  • \n
  • \u590d\u5236\u8d4b\u503c\u8fd0\u7b97\u7b26
  • \n
\n

\n\u91c7\u7528pImpl\u4e60\u60ef\u7528\u6cd5\u4e0d\u4f46\u52a0\u5feb\u7f16\u8bd1\u901f\u5ea6\uff0c\u800c\u4e14\u505a\u5230\u63a5\u53e3\u548c\u5b9e\u73b0\u7684\u771f\u6b63\u5206\u79bb\uff0c\u5c3d\u53ef\u80fd\u91c7\u7528\u6b64\u7528\u6cd5\u3002\n

\n
"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(3): RAII\u4e0e\u667a\u80fd\u6307\u9488", "url": "/2022/10/25/cpp_3.html", "content": "
\n

C++\u8bed\u8a00\u5bfc\u5b66(3): RAII\u4e0e\u667a\u80fd\u6307\u9488

\n\n
\n

1. \u5f15\u8a00

\n
\n

\nC++\u63d0\u4f9b\u5f00\u53d1\u8005\u81ea\u5b9a\u4e49\u7c7b\u578b\u7684\u80fd\u529b\uff0c\u800c\u5bf9\u4e8e\u81ea\u5b9a\u4e49\u7c7b\u578b\u7684\u8d44\u6e90\u7ba1\u7406\u662f\u4e00\u5927\u96be\u9898\u3002\n

\n

\n\u5bf9\u4e8e\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7c7b\u578b\u6216\u8005class\u6765\u8bf4\uff0c\u53ef\u4ee5\u76f4\u63a5\u521b\u5efa\u5b83\u7684\u5bf9\u8c61\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7new\u4e3a\u5b83\u521b\u5efa\u6307\u9488\u3002\n

\n

\n\u5bf9\u4e8e\u5bf9\u8c61\u548c\u6307\u9488\u7684\u8d44\u6e90\u7ba1\u7406\uff0c\u5206\u522b\u53ef\u4ee5\u4f7f\u7528RAII\u539f\u5219\u548c\u667a\u80fd\u6307\u9488\u6765\u5904\u7406\u3002\n

\n
\n
\n
\n

2. RAII: \u8d44\u6e90\u8bf7\u6c42\u5373\u521d\u59cb\u5316

\n
\n

\n\u5728\u6784\u9020\u51fd\u6570\u4e2d\u8bf7\u6c42\u8d44\u6e90\uff0c\u7136\u540e\u5728\u6790\u6784\u51fd\u6570\u4e2d\u91ca\u653e\u5b83\u4eec\u7684\u6280\u672f\u88ab\u79f0\u4e3a\u8d44\u6e90\u8bf7\u6c42\u5373\u521d\u59cb\u5316(RAII, Resource Acquisition Is Initialization)\u3002\n

\n

\n\u5f53\u6211\u4eec\u521b\u5efa(\u8bf7\u6c42)\u4e00\u4e2a\u5bf9\u8c61\u65f6\uff0c\u901a\u8fc7\u6784\u9020\u51fd\u6570\u5b83\u5df2\u7ecf\u81ea\u52a8\u521d\u59cb\u5316\u597d\u4e86\u8d44\u6e90\uff1b\u5f53\u5bf9\u8c61\u79bb\u5f00\u4f5c\u7528\u57df\u65f6\uff0c\u901a\u8fc7\u6790\u6784\u51fd\u6570\u5b83\u81ea\u52a8\u91ca\u653e\u4e86\u8d44\u6e90\u3002\n

\n

\n\u6574\u4e2a\u8fc7\u7a0b\u4e2d\u5bf9\u8c61\u7684\u8d44\u6e90\u4e0d\u518d\u7531\u8c03\u7528\u8005\u8d1f\u8d23\u7ba1\u7406\uff0c\u800c\u662f\u7531\u5f00\u53d1\u8005\u5728\u5bf9\u8c61\u5185\u90e8\u8bbe\u8ba1\u597d\u3002\n

\n

\n\u5982\u679c\u5bf9\u8c61\u5185\u90e8\u5b9e\u73b0\u6709\u7533\u8bf7\u5185\u5b58\uff0c\u5374\u53c8\u4e0d\u662f\u5728\u6790\u6784\u51fd\u6570\u4e2d\u91ca\u653e\u8d44\u6e90\uff0c\u90a3\u4e48\u5f53\u8fd9\u4e2a\u5bf9\u8c61\u79bb\u5f00\u4f5c\u7528\u57df\u88ab\u9500\u6bc1\u65f6\uff0c\u53ef\u80fd\u4f1a\u56e0\u4e3a\u8d44\u6e90\u6ca1\u6709\u5f97\u5230\u5b8c\u5168\u91ca\u653e\u800c\u9020\u6210\u5185\u5b58\u6cc4\u6f0f\u3002\n

\n

\n\u5e94\u8be5\u5c3d\u91cf\u907f\u514d\u5728\u4e00\u822c\u4ee3\u7801\u4e2d\u76f4\u63a5\u4f7f\u7528new\u548cdelete\uff0c\u800c\u662f\u8981\u9690\u85cf\u5728\u7c7b\u578b\u5185\u90e8\u5b9e\u73b0\uff0c\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u8d44\u6e90\u5f97\u5230\u53ca\u65f6\u7684\u91ca\u653e\u3002\n

\n

\n\u901a\u8fc7RAII\u539f\u5219\u53ef\u4ee5\u786e\u4fdd\u8d44\u6e90\u603b\u662f\u80fd\u591f\u901a\u8fc7\u6790\u6784\u51fd\u6570\u5f97\u5230\u91ca\u653e\u3002\n

\n

\n\u6bd4\u5982:\n

\n
\n
class Vector{\npublic:\n    Vector(int s): elem{new elem[s]}, sz{s}  // \u5206\u914d\u8d44\u6e90\n    {\n        for(int i=0; i != s; i++)  // \u521d\u59cb\u5316\n           elem[i] = 0;\n    }\n\n   ~Vector(){ delete[] elem; }   // \u6790\u6784\u51fd\u6570\u91ca\u653e\u8d44\u6e90\n\n   double& operator[](int i);\n   int size() const;\nprivate:\n   double *elem;\n   int sz;\n};\n
\n
\n

\n\u90a3\u4e48\u5728\u4f7f\u7528\u7684\u65f6\u5019\u5c31\u53ef\u4ee5\u5f53\u5bf9\u8c61\u79bb\u5f00\u4f5c\u7528\u57df\u65f6\u81ea\u52a8\u8c03\u7528\u6790\u6784\u51fd\u6570\u5b8c\u6210\u8d44\u6e90\u7684\u91ca\u653e:\n

\n
\n
void fct(int n)\n{\n    Vector v(n);\n    {\n        Vector v2(2*n);\n    } // v2\u5728\u6b64\u9500\u6bc1\n} // v\u5728\u6b64\u9500\u6bc1\n
\n
\n

\n\u6784\u9020\u51fd\u6570\u4e0e\u6790\u6784\u51fd\u6570\u8fd9\u5957RAII\u673a\u5236\u662f\u5927\u591a\u6570C++\u901a\u7528\u8d44\u6e90\u7ba1\u7406\u6280\u672f\u7684\u57fa\u7840\u3002\n

\n
\n
\n
\n

3. \u667a\u80fd\u6307\u9488

\n
\n

\nnew\u8fd0\u7b97\u7b26\u662f\u4ece\u4e00\u5757\u540d\u4e3a\u81ea\u7531\u5b58\u50a8\u6216\u52a8\u6001\u5185\u5b58(dynamic memory)\u7684\u533a\u57df\u4e2d\u5206\u914d\u5185\u5b58\u3002\n

\n

\n\u5728\u81ea\u7531\u5b58\u50a8\u4e2d\u5206\u914d\u7684\u5bf9\u8c61\u72ec\u7acb\u4e8e\u5b83\u521b\u5efa\u65f6\u6240\u5904\u7684\u4f5c\u7528\u57df\uff0c\u4f1a\u4e00\u76f4\u201c\u5b58\u6d3b\u201d\u5230\u4f7f\u7528delete\u8fd0\u7b97\u7b26\u9500\u6bc1\u5b83\u4e3a\u6b62\u3002\n

\n

\n\u800c\u4f7f\u7528\u201c\u88f8\u201dnew\u548cdelete\u5f88\u5bb9\u6613\u51fa\u5dee\uff0c\u56e0\u4e3a\u4f1a\u51fa\u4e8e\u5404\u79cd\u539f\u56e0\u5fd8\u8bb0\u4f7f\u7528delete\u6216\u8005\u7a0b\u5e8f\u903b\u8f91\u5230\u4e0d\u4e86delete\u8bed\u53e5\u5c31\u5df2\u7ecf\u8fd4\u56de\u4e86\u3002\n

\n

\n\u8fd9\u4e2a\u65f6\u5019\u4e0d\u662fRAII\u539f\u5219\u4e0d\u8d77\u4f5c\u7528\uff0c\u800c\u662f\u6ca1\u6709\u81ea\u52a8\u8c03\u7528\u6790\u6784\u51fd\u6570\u6765\u5b9e\u73b0RAII\u539f\u5219\uff0c\u53ef\u4ee5\u901a\u8fc7\u667a\u80fd\u6307\u9488\u6765\u8ba9\u5b83\u81ea\u52a8\u8c03\u7528\u6790\u6784\u51fd\u6570\u3002\n

\n

\n\u6bd4\u5982:\n

\n
\n
void user(int x)\n{\n    Shape *p = new Circle{Point{0,0}, 10};\n    //...\n    if(x < 0) throw Bad_x{};  // \u5b58\u5728\u6cc4\u6f0f\u5371\u9669\n    if(x < 0) return;         // \u5b58\u5728\u6cc4\u6f0f\u5371\u9669\n    //...\n    delete p;\n}\n
\n
\n

\n\u5728x\u4e0d\u662f\u6b63\u6570\u7684\u65f6\u5019\uff0c\u51fd\u6570\u76f4\u63a5\u8fd4\u56de\u4e86\uff0c\u800c\u6307\u9488p\u5e76\u6ca1\u6709\u6267\u884c\u5230delete\u8bed\u53e5\uff0c\u9020\u6210\u201c\u88f8\u6307\u9488\u201d\u95ee\u9898\u3002\n

\n

\n\u5982\u679c\u8bf4\u6709\u4e00\u79cd\u65b9\u6cd5\uff0c\u5728\u6307\u9488p\u79bb\u5f00\u8fd9\u4e2a\u4f5c\u7528\u57df\u7684\u65f6\u5019\u77e5\u9053\u81ea\u52a8\u9500\u6bc1\u6307\u9488p\u7684\u8bdd\uff0c\u90a3\u4e48\u5c31\u80fd\u591f\u907f\u514d\u8fd9\u4e2a\u95ee\u9898\uff0c\u8fd9\u5c31\u662f\u667a\u80fd\u6307\u9488\uff1a\n

\n
    \n
  • std::unique_ptr\uff1a\u552f\u4e00\u6240\u6709\u6743\uff0c\u7ba1\u7406\u5177\u5907\u4e13\u5c5e\u6240\u6709\u6743\u7684\u8d44\u6e90
  • \n
  • std::shared_ptr\uff1a\u5171\u4eab\u6240\u6709\u6743\uff0c\u7ba1\u7406\u5177\u5907\u5171\u4eab\u6240\u6709\u6743\u7684\u8d44\u6e90
  • \n
  • std::weak_ptr: \u5bf9\u4e8e\u7c7b\u4f3cstd::shared_ptr\u4f46\u6709\u53ef\u80fd\u7a7a\u60ac\u7684\u6307\u9488
  • \n
\n
\n
\n

3.1. std::unique_ptr

\n
\n
\n
class Smiley: public Circle {\n    //...\nprivate:\n    vector<unique_ptr<Shape>> eyes;\n    uniq_ptr<Shape> mouth;\n};\n\nunique_ptr<Shape> read_shape(istream& is)\n{\n    //....\n    return unique_ptr<Shape>{new Circle{p,r}};\n}\n\nvoid user()\n{\n   vector<unique_ptr<Shape>> v;\n   while(cin)\n      v.push_back(read_shape(cin));\n   //...\n}\n
\n
\n

\n\u5f53\u5bf9\u8c61\u88abunique_ptr\u6240\u62e5\u6709\u540e\uff0c\u4f46\u4e0d\u518d\u9700\u8981\u8fd9\u4e2a\u5bf9\u8c61\u65f6\uff0c\u6bd4\u5982\u5bf9\u8c61\u7684unique_ptr\u79bb\u5f00\u4f5c\u7528\u57df\uff0c\u5b83\u4f1a\u81ea\u52a8\u8c03\u7528delete\u91ca\u653e\u5bf9\u8c61\u3002\n

\n

\nstd::unique_ptr\u53ea\u80fd\u79fb\u52a8(std::move)\u4e0d\u80fd\u62f7\u8d1d\uff1a\n

\n
\n
void f1()\n{\n    auto p = make_unique<int>(2);\n    auto q = p;            // \u9519\u8bef\uff0c\u4e0d\u80fd\u62f7\u8d1d\n    auto q = std::move(p); // \u4e4b\u540ep\u7b49\u4e8enullptr,\u540e\u7eedp\u4e0d\u80fd\u518d\u4f7f\u7528\u4e86\n}\n
\n
\n
\n
\n
\n

3.2. std::shared_ptr

\n
\n

\nshared_ptr\u5f88\u591a\u65b9\u9762\u548cunique_ptr\u975e\u5e38\u76f8\u4f3c\uff0c\u552f\u4e00\u7684\u533a\u522b\u662fshared_ptr\u7684\u5bf9\u8c61\u662f\u4f7f\u7528\u62f7\u8d1d\u64cd\u4f5c\uff0c\u800cunique_ptr\u4f7f\u7528\u79fb\u52a8\u8bed\u4e49\u3002\n

\n

\n\u6bd4\u5982:\n

\n
\n
void f(shared_ptr<fstream>);\nvoid g(shared_ptr<fstream>);\n\nvoid user(const string& name, ios_base::openmode mode)\n{\n    shared_ptr<fstream> fp{new fstream(name, mode)};\n\n    if(!*fp) throw No_file{};\n\n    f(fp);\n    g(fp);\n    //...\n}\n
\n
\n

\n\u6bcf\u6b21\u8c03\u7528\u90fd\u62e5\u6709\u8fd9\u4e2a\u5171\u4eab\u667a\u80fd\u6307\u9488\u7684\u4e00\u4efd\u62f7\u8d1d\uff0c\u5f53\u6700\u540e\u4e00\u4e2a\u62f7\u8d1d\u9500\u6bc1\u7684\u65f6\u5019\u5c31\u91ca\u653e\u5bf9\u5e94\u7684\u8d44\u6e90\u4e86\u3002\n

\n
\n
\n
\n

3.3. make_unique, make_shared

\n
\n
\n
auto p1 = make_unique<S>(2,\"Oz\",7.62);\nauto p2 = make_shared<S>(1,\"Ankh Morpork\",4.65);\n
\n
\n

\n\u901a\u8fc7\u6807\u51c6\u5e93memory\u4e2d\u63d0\u4f9b\u7684\u51fd\u6570\u81ea\u52a8\u83b7\u53d6\u5bf9\u5e94\u7684\u667a\u80fd\u6307\u9488\uff0c\u4ece\u800c\u9632\u6b62\u4f7f\u7528\u4e86new\u5374\u53c8\u5fd8\u8bb0\u4ea4\u7ed9\u667a\u80fd\u6307\u9488\u6765\u7ba1\u7406\u3002\n

\n
\n
\n
\n

3.4. \u4f55\u65f6\u4f7f\u7528\u667a\u80fd\u6307\u9488\uff1f

\n
\n
    \n
  • \u5f53\u9700\u8981\u667a\u80fd\u6307\u9488\u65f6\uff0c\u57fa\u672c\u4e0astd::uniq_ptr\u662f\u9996\u9009
  • \n
  • \u5f53\u5171\u4eab\u67d0\u4e2a\u5bf9\u8c61\u65f6\uff0c\u9700\u8981\u6307\u5411\u5171\u4eab\u5bf9\u8c61\u7684\u6307\u9488\u6216\u5f15\u7528\uff0c\u9009\u62e9shared_ptr
  • \n
  • \u5f53\u5f15\u7528\u4e00\u4e2a\u591a\u6001\u5bf9\u8c61\u65f6\uff0c\u5f88\u96be\u77e5\u9053\u5bf9\u8c61\u5230\u5e95\u662f\u4ec0\u4e48\u7c7b\u578b\uff0c\u5219\u9700\u8981\u4e00\u4e2a\u6307\u9488\uff0c\u6b64\u65f6unique_ptr\u662f\u5fc5\u7136\u9009\u62e9
  • \n
  • \u5171\u4eab\u7684\u591a\u6001\u5bf9\u8c61\u901a\u5e38\u9700\u8981shared_ptr
  • \n
  • \u4f18\u5148\u4f7f\u7528make_unique\u548cmake_shared\uff0c\u800c\u4e0d\u662f\u81ea\u5df1\u6765new
  • \n
\n
\n
\n
\n
\n

4. \u603b\u7ed3

\n
\n
    \n
  • \u5bf9\u4e8e\u81ea\u5b9a\u4e49\u7c7b\u578b\uff0c\u4f7f\u7528RAII\u539f\u5219\u7ba1\u7406\u8d44\u6e90\u7684\u7533\u8bf7\u4e0e\u91ca\u653e\uff0c\u5185\u90e8\u5b9e\u73b0\u4e2d\u6784\u9020\u51fd\u6570\u548c\u6790\u6784\u51fd\u6570\u5206\u522b\u4f7f\u7528new\u548cdelete
  • \n
  • \u5f53\u9700\u8981\u4f7f\u7528\u6307\u9488\u65f6\uff0c\u4f18\u5148\u4f7f\u7528\u667a\u80fd\u6307\u9488\uff0c\u5e76\u4e14\u4f7f\u7528make_unique\u548cmake_shared\u521b\u5efa\u667a\u80fd\u6307\u9488\uff0c\u4e00\u822c\u4ee3\u7801\u91cc\u9762\u4e0d\u9700\u8981\u51fa\u73b0new\u548cdelete
  • \n
\n
\n
\n
"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(2): \u6a21\u5757\u5316", "url": "/2022/10/23/cpp_2.html", "content": "
\n

C++\u8bed\u8a00\u5bfc\u5b66(2): \u6a21\u5757\u5316

\n\n
\n

1. \u5f15\u8a00

\n
\n

\n\u7a0b\u5e8f\u7ec4\u7ec7\u7684\u6700\u4f73\u65b9\u5f0f\u662f\u5c06\u7a0b\u5e8f\u770b\u4f5c\u4f9d\u8d56\u5173\u7cfb\u5b9a\u4e49\u826f\u597d\u7684\u4e00\u7ec4\u6a21\u5757\uff0c\u5728\u903b\u8f91\u4e0a\u901a\u8fc7\u8bed\u8a00\u7279\u6027\u8868\u8fbe\u6a21\u5757\u5316\uff0c\u5728\u7269\u7406\u4e0a\u901a\u8fc7\u6587\u4ef6\u6a21\u5757\u5316\u5b9e\u73b0\u9ad8\u6548\u7684\u5206\u522b\u7f16\u8bd1\u3002\n

\n

\n\u7a0b\u5e8f\u6e90\u7801\u6587\u4ef6\u6a21\u5757\u5316\u6700\u91cd\u8981\u7684\u4e00\u6b65\u662f\u5c06\u6bcf\u4e2a\u7ec4\u6210\u90e8\u5206\u7684\u63a5\u53e3\u548c\u5b9e\u73b0\u5206\u79bb\u5f00\u6765\uff0c\u501f\u52a9\u5206\u522b\u7f16\u8bd1\u3001\u540e\u7eed\u94fe\u63a5\u7684\u65b9\u5f0f\u63d0\u9ad8\u7f16\u8bd1\u6548\u7387\u3002\n

\n

\n\u4ee5\u5f80\u662f\u901a\u8fc7\u5934\u6587\u4ef6(*.hpp)\u548c\u5b9e\u73b0\u6587\u4ef6(*.cpp)\u6765\u8fbe\u5230\u5206\u79bb\u76ee\u7684\uff0c\u5728\u7f16\u8bd1\u4e3a\u52a8\u6001\u94fe\u63a5\u5e93(*.so)\u4f9b\u5176\u4ed6\u4eba\u4f7f\u7528\u7684\u65f6\u5019\u7279\u522b\u65b9\u4fbf\uff0c\u53ef\u4ee5\u8fbe\u5230\u9690\u85cf\u7ec6\u8282\u7684\u76ee\u7684\u3002\n

\n

\n\u4f46\u4f7f\u7528 #include \u662f\u4e00\u79cd\u53e4\u8001\u3001\u6613\u51fa\u9519\u4e14\u4ee3\u4ef7\u4e0d\u5c0f\u7684\u7a0b\u5e8f\u6a21\u5757\u5316\u7ec4\u7ec7\u65b9\u5f0f\uff0c\u4eceC++20\u5f00\u59cb\u5f15\u5165 module \u7279\u6027\uff0cGCC11\u652f\u6301\u6b64\u529f\u80fd:\n

\n
\n

\n$ g++ -std=c++20 -fmodules-ts file.cpp\n

\n
\n

\n\u4f7f\u7528\u6a21\u5757\u529f\u80fd\u53ef\u4ee5\u63d0\u9ad8\u7f16\u8bd1\u6548\u7387\u548c\u53ef\u7ef4\u62a4\u6027:\n

\n
    \n
  • \u4e00\u4e2a\u6a21\u5757\u53ea\u4f1a\u7f16\u8bd1\u4e00\u6b21\uff0c\u800cinclude\u53ea\u8981\u5305\u542b\u4e00\u6b21\u5c31\u4f1a\u7f16\u8bd1\u4e00\u6b21
  • \n
  • \u4e24\u4e2a\u6a21\u5757\u53ef\u4ee5\u6309\u4efb\u610f\u987a\u5e8f\u5bfc\u5165\u800c\u4e0d\u4f1a\u6539\u53d8\u5b83\u4eec\u7684\u542b\u4e49
  • \n
  • import\u6ca1\u6709\u4f20\u9012\u6027
  • \n
\n

\n\u4f46\u76ee\u524d\u6765\u770b\uff0c\u4f7f\u7528module\u529f\u80fd\u4e0d\u662f\u90a3\u4e48\u5bb9\u6613\uff0c\u5c24\u5176\u662f\u65e7\u4ee3\u7801\u8fc1\u79fb\u3001\u65b0\u65e7\u4ee3\u7801\u5e76\u5b58\u7f16\u8bd1\u4f1a\u662f\u4e00\u4e2a\u4e0d\u5c0f\u7684\u6311\u6218\u3002\n

\n

\n\u53e6\u5916\uff0c\u4ee3\u7801\u7684\u9759\u6001\u5e93\u3001\u4e8c\u8fdb\u5236\u7b49\u5206\u53d1\u4f1a\u6bd4\u8f83\u56f0\u96be\uff0c\u7ec6\u5fae\u7684ABI\u5dee\u5f02\u90fd\u5bfc\u81f4\u65e0\u6cd5\u5171\u4eab\u4f7f\u7528\u3002\n

\n
\n
\n
\n

2. module\u4f8b\u5b50: \u5934\u6587\u4ef6\u53d8\u6210\u6a21\u5757

\n
\n

\nhello.hpp:\n

\n
\n
constexpr int num=3;\n
\n
\n

\nrun.cpp:\n

\n
\n
import \"hello.hpp\";\n
\n
\n

\n\u9700\u8981\u5148\u5c06\u8fd9\u4e2a\u5355\u72ec\u7684\u5934\u6587\u4ef6\u7f16\u8bd1\u4e3a\u6a21\u5757\u540e\u624d\u80fdimport\u4f7f\u7528:\n

\n
\n$ g++ -c -std=c++20 -fmodule-header hello.hpp  # \u751f\u6210gcm.cache/,/hello.hpp.gcm\n$ g++ -c -std=c++20 -fmodules-ts run.cpp       # \u751f\u6210run.o\n
\n
\n
\n
\n

3. module\u4f8b\u5b50: \u6a21\u5757\u63a5\u53e3\u548c\u5b9e\u73b0\u5728\u4e00\u8d77

\n
\n

\nVector.cpp\n

\n
\n
module;\n\nexport module Vector;\n\nexport class Vector{\npublic:\n    Vector(int s);\n    double& operator[](int i);\n    int size() const;\nprivate:\n    double *elem;\n    int sz;\n};\n\nVector::Vector(int s)\n    :elem{new double[s]}, sz{s}\n    {\n    }\n\ndouble& Vector::operator[](int i){\n    return elem[i];\n}\n\nint Vector::size() const{\n    return sz;\n}\n\nexport int size(const Vector& v){ return v.size(); }\n
\n
\n

\nmain.cpp:\n

\n
\n
import Vector;\n\n#include <iostream>\n#include <cmath>\n\ndouble sqrt_sum(Vector& v)\n{\n    double sum = 0;\n    for(int i=0; i != v.size(); i++)\n    {\n        sum += std::sqrt(v[i]);\n    }\n\n    return sum;\n}\n\nint main()\n{\n    Vector v(5);\n    v[0] = 1;\n    v[1] = 2;\n    v[2] = 3;\n    v[3] = 4;\n\n    double sum = sqrt_sum(v);\n    std::cout << \"size: \" << size(v) << \", sum: \" << sum << std::endl;\n    return 0;\n}\n
\n
\n

\n\u7f16\u8bd1\u4e0e\u6267\u884c:\n

\n
\n$ g++ -c -std=c++20  -fmodules-ts Vector.cpp  # \u521b\u5efaVector.o\u548cgcm.cache/Vector.gcm\n$ g++ -c -std=c++20  -fmodules-ts main.cpp    # \u521b\u5efamain.o\n$ g++ main.o Vector.o -o main                 # \u521b\u5efamain\n\nor\n\n$ g++ -std=c++20 -fmodules-ts Vector.cpp main.cpp -o main\n\n$ ./main\nsize: 5, sum: 6.14626\n
\n

\n\u67e5\u770b\u6a21\u5757\u6587\u4ef6\u4fe1\u606f(.gcm):\n

\n
\n$ readelf -p.gnu.c++.README gcm.cache/Vector.gcm\n\nString dump of section '.gnu.c++.README':\n  [     0]  GNU C++ primary module interface\n  [    21]  compiler: 11.2.1 20210728 (Red Hat 11.2.1-1)\n  [    4e]  version: 2021/07/28-09:09\n  [    68]  module: Vector\n  [    77]  source: Vector.cpp\n  [    8a]  dialect: C++20/coroutines\n  [    df]  repository: gcm.cache\n
\n
\n
\n
\n

4. module\u4f8b\u5b50: \u6a21\u5757\u63a5\u53e3\u4e0e\u5b9e\u73b0\u5206\u79bb

\n
\n

\nVector.cpp:\n

\n
\n
module;\n\nexport module Vector;\n\nexport class Vector{\npublic:\n    Vector(int s);\n    double& operator[](int i);\n    int size() const;\nprivate:\n    double *elem;\n    int sz;\n};\n\n\nexport int size(const Vector& v);\n
\n
\n

\nVector_impl.cpp:\n

\n
\n
module;\n\nmodule Vector;\n\n\nVector::Vector(int s)\n    :elem{new double[s]}, sz{s}\n    {\n    }\n\ndouble& Vector::operator[](int i){\n    return elem[i];\n}\n\nint Vector::size() const{\n    return sz;\n}\n\nint size(const Vector& v){ return v.size(); }\n
\n
\n

\nmain.cpp:\n

\n
\n
#include <iostream>\n#include <cmath>\n\nimport Vector;\n\ndouble sqrt_sum(Vector& v)\n{\n    double sum = 0;\n    for(int i=0; i != v.size(); i++)\n    {\n        sum += std::sqrt(v[i]);\n    }\n\n    return sum;\n}\n\nint main()\n{\n    Vector v(5);\n    v[0] = 1;\n    v[1] = 2;\n    v[2] = 3;\n    v[3] = 4;\n\n    double sum = sqrt_sum(v);\n    std::cout << \"size: \" << size(v) << \", sum: \" << sum << std::endl;\n    return 0;\n}\n
\n
\n

\n\u7f16\u8bd1\u4e0e\u6267\u884c:\n

\n
\n$ g++ -c -std=c++20 -fmodules-ts Vector.cpp      # \u751f\u6210Vector.o\u548cgcm.cache/Vector.gcm\n$ g++ -c -std=c++20 -fmodules-ts Vector_impl.cpp # \u751f\u6210Vector_impl.o\n$ g++ -c -std=c++20 -fmodules-ts main.cpp        # \u751f\u6210main.o\n$ g++ -std=c++20 -fmodules-ts main.o Vector_impl.o Vector.o -o main\n\nor\n\n$ g++ -std=c++20 -fmodules-ts Vector.cpp Vector_impl.cpp main.cpp -o main\n
\n

\n\u6ce8\u610f, Vector.cpp\u5982\u679c\u6587\u4ef6\u540d\u6539\u6210Vector.hpp\u5219\u4f1a\u8ba4\u4e3a\u662f\u666e\u901a\u5934\u6587\u4ef6\uff0c\u800c\u4e0d\u662f\u6a21\u5757\u7684\u63a5\u53e3\u6587\u4ef6(cmi)\uff0c\u9700\u52a0\u4e0a -x c++ \u9009\u9879: \n

\n
\n$ g++ -c -std=c++20 -fmodules-ts Vector.hpp   # \u4f1a\u76f4\u63a5\u5f53\u505a\u666e\u901a\u7684\u5934\u6587\u4ef6\u5904\u7406\u800c\u62a5\u9519\nVector.hpp:1:1: error: module-declaration not permitted in header-unit\n\n$ g++ -c -std=c++20 -fmodules-ts -x c++ Vector.hpp  # \u8ba9\u7f16\u8bd1\u5668\u81ea\u5df1\u5224\u65ad\u51fa\u662fmodule\u63a5\u53e3\u6587\u4ef6(cmi)\n$ g++ -c -std=c++20 -fmodules-ts -x c++ Vector.hpp Vector_impl.cpp\n$ g++ -std=c++20 -fmodules-ts -x c++ Vector.hpp Vector_impl.cpp main.cpp -o main\n
\n
\n
\n
\n

5. module\u4f8b\u5b50\uff1a\u5b50\u6a21\u5757

\n
\n
    \n
  • \u5b50\u6a21\u5757: TestMod.Vector
  • \n
\n

\nVector.hpp:\n

\n
\n
module;\n\nexport module TestMod.Vector;  // \u8fd9\u91cc\u5176\u5b9e\u662f\u4e00\u4e2a\u5b8c\u6574\u7684\u6a21\u5757\u540d\u5b57\uff0c\u8fd9\u4e2a'.'\u6ca1\u6709\u4efb\u4f55\u4ece\u5c5e\u610f\u4e49\n\nexport class Vector{\npublic:\n    Vector(int s);\n    double& operator[](int i);\n    int size() const;\nprivate:\n    double *elem;\n    int sz;\n};\n\n\nexport int size(const Vector& v);\n
\n
\n

\nVector.cpp:\n

\n
\n
module;\n\nmodule TestMod.Vector;\n\n\nVector::Vector(int s)\n    :elem{new double[s]}, sz{s}\n    {\n    }\n\ndouble& Vector::operator[](int i){\n    return elem[i];\n}\n\nint Vector::size() const{\n    return sz;\n}\n\nint size(const Vector& v){ return v.size(); }\n
\n
\n
    \n
  • \u5b50\u6a21\u5757: TestMod.funcs
  • \n
\n

\nfuncs.hpp:\n

\n
\n
export module TestMod.funcs;\n\nexport void func1();\nexport void func2();\n
\n
\n

\nfuncs.cpp:\n

\n
\n
module;\n\n#include <iostream>\n\nmodule TestMod.funcs;\n\nvoid func1(){\n    std::cout << \"func1\" << std::endl;\n}\n\nvoid func2(){\n    std::cout << \"func2\" << std::endl;\n}\n
\n
\n
    \n
  • \u6a21\u5757: TestMod
  • \n
\n

\nTestMod.hpp:\n

\n
\n
export module TestMod;\nexport import TestMod.Vector;\nexport import TestMod.funcs;\n
\n
\n
    \n
  • main.cpp
  • \n
\n
\n
#include <iostream>\n#include <cmath>\n\nimport TestMod;\n\ndouble sqrt_sum(Vector& v)\n{\n    double sum = 0;\n    for(int i=0; i != v.size(); i++)\n    {\n        sum += std::sqrt(v[i]);\n    }\n\n    return sum;\n}\n\nint main()\n{\n    Vector v(5);\n    v[0] = 1;\n    v[1] = 2;\n    v[2] = 3;\n    v[3] = 4;\n\n    double sum = sqrt_sum(v);\n    std::cout << \"size: \" << size(v) << \", sum: \" << sum << std::endl;\n\n    func1();\n    func2();\n\n    return 0;\n}\n
\n
\n

\n\u7f16\u8bd1:\n

\n
\n$ g++ -c -std=c++20 -fmodules-ts -x c++ Vector.hpp Vector.cpp\n$ g++ -c -std=c++20 -fmodules-ts -x c++ funcs.hpp funcs.cpp\n$ g++ -c -std=c++20 -fmodules-ts -x c++ TestMod.hpp\n\n$ g++ -c -std=c++20 -fmodules-ts -x c++ Vector.hpp Vector.cpp funcs.hpp funcs.cpp TestMod.hpp\n\n$ g++ -std=c++20 -fmodules-ts -x c++ Vector.hpp Vector.cpp funcs.hpp funcs.cpp TestMod.hpp main.cpp -o main\n\n$ ./main\nsize: 5, sum: 6.14626\nfunc1\nfunc2\n
\n
\n
\n
\n

6. \u8d44\u6599

\n\n
\n
"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(1): \u57fa\u7840\u77e5\u8bc6", "url": "/2022/10/22/cpp_1.html", "content": "
\n

C++\u8bed\u8a00\u5bfc\u5b66(1): \u57fa\u7840\u77e5\u8bc6

\n\n
\n

1. \u524d\u8a00

\n
\n
\n

\n\u8981\u60f3\u5199\u51fa\u597d\u7684C++\u7a0b\u5e8f\uff0c\u4e0d\u5fc5\u4e86\u89e3C++\u7684\u6240\u6709\u7ec6\u8282\u3002\n

\n
\n

\n\u4ee5C++17\u6807\u51c6\u4e3a\u6700\u65b0\u5b9a\u4e49\uff0c\u5feb\u901f\u4e86\u89e3\u73b0\u4ee3C++\u8bed\u8a00:\n

\n
\n$ g++ -std=c++17 file.cpp\n
\n
\n
\n
\n

2. auto\u4e0e\u5217\u8868\u521d\u59cb\u5316

\n
\n

\n\u53d8\u91cf\u4f18\u5148\u4f7f\u7528\u901a\u7528\u7684\u5217\u8868\u521d\u59cb\u5316\u5f62\u5f0f {} \uff0c\u4ee5\u907f\u514d\u5728\u7c7b\u578b\u8f6c\u6362\u4e2d\u4e22\u5931\u4fe1\u606f:\n

\n
\n
int i1 = 7.8; // i1\u53d8\u6210\u4e867\uff0c\u9690\u5f0f\u6536\u7f29\u8f6c\u6362\nint i2 {7.8};  // \u9519\u8bef: \u6d6e\u70b9\u6570\u5411\u6574\u6570\u8f6c\u6362\nint i2 = {7.8};  // \u9519\u8bef: \u6d6e\u70b9\u6570\u5411\u6574\u6570\u8f6c\u6362\n
\n
\n

\n\u53d8\u91cf\u7c7b\u578b\u5728\u6ca1\u6709\u7279\u6b8a\u7406\u7531\u9700\u8981\u663e\u5f0f\u6307\u5b9a\u6570\u636e\u7c7b\u578b\u65f6\uff0c\u4e00\u822c\u4f7f\u7528 auto :\n

\n
\n
auto b = true;    // bool\nauto ch = 'x';    // char\nauto i = 123;     // int\nauto d = 1.2;     // double\nauto z = sqrt(y); // sqrt\u7684\u8fd4\u56de\u7c7b\u578b\nauto bb {true};   // bool\n
\n
\n

\n\u7279\u6b8a\u7406\u7531\u5305\u62ec:\n

\n
    \n
  • \u4f4d\u4e8e\u4e00\u4e2a\u8f83\u5927\u7684\u4f5c\u7528\u57df\u4e2d\uff0c\u5e0c\u671b\u63d0\u9ad8\u4ee3\u7801\u7684\u6613\u8bfb\u6027\uff0c\u660e\u786e\u6570\u636e\u7c7b\u578b
  • \n
  • \u9700\u8981\u660e\u786e\u4e00\u4e2a\u53d8\u91cf\u7684\u8303\u56f4\u548c\u7cbe\u5ea6\uff0c\u6bd4\u5982\u5e0c\u671b\u4f7f\u7528double\u800c\u4e0d\u662ffloat
  • \n
\n
\n
\n
\n

3. \u7a7a\u6307\u9488: nullptr

\n
\n

\n\u4e0d\u518d\u4f7f\u7528 0 \u6216 NULL \u8868\u793a\u7a7a\u6307\u9488\uff0c\u4f7f\u7528 nullptr \uff0c\u6240\u6709\u6307\u9488\u7c7b\u578b\u90fd\u5171\u4eab\u540c\u4e00\u4e2a nullptr.\n

\n

\n\u68c0\u9a8c\u53d8\u91cf\u662f\u5426\u4e3a 0 \u6216 nullptr \u5c3d\u91cf\u91c7\u7528\u7b80\u6d01\u5f62\u5f0f:\n

\n
\n
while(*p) // \u7b49\u540c: while(*p != 0)\n{\n  //...\n}\n\nif(p)  // \u7b49\u540c: if(p != nullptr)\n{\n  //...\n}\n\nvoid do_something(const vector<int>& v)\n{\n    if(auto n = v.size())\n    {\n        // n != 0\n    }\n}\n
\n
\n
\n
\n
\n

4. \u5c3d\u91cf\u4e0d\u76f4\u63a5\u4f7f\u7528union

\n
\n

\n\u6bd4\u5982\u6709\u8fd9\u6837\u4e00\u4e2a\u8054\u5408\u7684\u5b9a\u4e49:\n

\n
\n
enum Type {ptr, num };\n\nunion Value {\n    Node *p;\n    int i;\n};\n\nstruct Entry {\n    Type t;\n    Value v;\n};\n\nvoid f(Entry* pe) {\n    if(pe->t == num) {\n        cout << pe->v.i;\n    }\n}\n
\n
\n

\n\u5c3d\u91cf\u5c11\u4f7f\u7528\u8fd9\u79cd\u539f\u59cbunion\u5f62\u5f0f\uff0c\u6539\u4e3a\u4f7f\u7528\u6807\u51c6\u5e93\u7c7b\u578bvariant\uff0c\u5e76\u4e14\u5e94\u8be5\u5c01\u88c5\u5230\u4e00\u4e2a\u7c7b\u5185\u90e8\u4ece\u800c\u53ea\u4e3a\u5b83\u670d\u52a1:\n

\n
\n
#include <variant>\n\nstruct Entry {\n    Type t;\n    std::variant<Node *, int> v;\n};\n\nvoid f(Entry* pe) {\n    if(std::holds_alternative<int>(pe->v)){\n        std::cout << std::get<int>(pe->v);\n    }\n}\n
\n
\n
\n
\n
\n

5. \u679a\u4e3e\u4f18\u5148\u4f7f\u7528enum class

\n
\n

\n\u4ee5\u5f80\u7684enum\u4e2d\u679a\u4e3e\u503c\u4f5c\u7528\u57df\u4e0eenum\u4f5c\u7528\u57df\u4e00\u81f4\uff0c\u9690\u5f0f\u8f6c\u6362\u4e3aint\u7c7b\u578b\u503c:\n

\n
\n
enum Color {red, green, blue};  // \u4ece0\u5f00\u59cb\nenum Clolor2 {red2=1, green2, blue2};  // \u4ece1\u5f00\u59cb\n\nint col = green; // 1\nint col2 = green2; // 2\n
\n
\n

\n\u4f7f\u7528\u5e26\u5f3a\u7c7b\u578b\u7684\u679a\u4e3e\u5219\u4e0d\u4f1a\u51fa\u73b0\u540d\u5b57\u51b2\u7a81\uff0c\u800c\u4e14\u907f\u514d\u4e86\u9690\u5f0f\u8f6c\u6362:\n

\n
\n
enum class Color;  // \u53ef\u4ee5\u524d\u7f6e\u58f0\u660e\n\nenum class Color { red, green, blue};\nenum class Color2 { red=1, green, blue};\n\nColor col = Color::green;\nColor2 col2 = Color2::green;\n\nint col_i = static_cast<int>(Color::green); // 1, \u9700\u8981\u663e\u5f0f\u8f6c\u6362\u4e3aint\nint col2_i = static_cast<int>(Color2::green); // 2\n
\n
\n
\n
\n
"}, {"title": "\u5988\uff0c\u6211\u60f3\u8981\u4e00\u672c\u5b57\u5178\uff01", "url": "/2020/05/10/I_want_a_dictionary.html", "content": "
\n

\u5988\uff0c\u6211\u60f3\u8981\u4e00\u672c\u5b57\u5178\uff01

\n

\n\u8fd9\u5929\u662f\u5468\u65e5\uff0c\u4e5f\u6b63\u597d\u662f\u6bcd\u4eb2\u8282\uff0c\u4f46\u5ab3\u5987\u5374\u9700\u8981\u4e0a\u73ed\uff0c\u65e0\u6cd5\u966a\u5b69\u5b50\u4e00\u8d77\u8fc7\u8282\u3002\n

\n

\n\u5b69\u5b50\u4e94\u516d\u5c81\u4e86\uff0c\u65e9\u4e0a\u548c\u5b69\u5b50\u4e00\u8d77\u6d17\u6f31\u7684\u65f6\u5019\uff0c\u5b69\u5b50\u95ee\uff1a\u201c\u5988\u5988\u5462\uff1f\u201d\n

\n

\n\u6211\u5f88\u9ad8\u5174\u5b69\u5b50\u4f1a\u4e3b\u52a8\u95ee\u8d77\u5988\u5988\uff0c\u4e5f\u660e\u767d\u5b83\u4e3a\u4ec0\u4e48\u4f1a\u8fd9\u6837\u95ee\uff0c\u56e0\u4e3a\u4e00\u822c\u5468\u672b\u7684\u65e9\u4e0a\u662f\u5988\u5988\u966a\u4ed6\u6d17\u6f31\u7684\u3002\n

\n

\n\u6211\u5e26\u70b9\u53f9\u606f\u8bf4\u9053\uff1a\u201c\u5988\u5988\u53bb\u4e0a\u73ed\u4e86\u554a\u3002\u3002\u3002\u201d\n

\n

\n\u5b69\u5b50\u671b\u7740\u6211\uff0c\u8ffd\u95ee\u9053\uff1a\u201c\u4e3a\u4ec0\u4e48\u8981\u4e0a\u73ed\u5462\uff1f\u4eca\u5929\u4e0d\u662f\u6bcd\u4eb2\u8282\u5417\uff1f\u201d\n

\n

\n\u6211\u4e00\u65f6\u4e0d\u77e5\u5982\u4f55\u56de\u7b54\u3002\n

\n

\n\u6628\u5929\u665a\u4e0a\u5ab3\u5987\u4e0b\u73ed\u56de\u6765\u540e\uff0c\u5df2\u7ecf\u4e3a\u5bb6\u91cc\u505a\u4e86\u4e00\u4e2a\u86cb\u7cd5\uff0c\u5c31\u5f53\u662f\u966a\u5b69\u5b50\u8fc7\u6bcd\u4eb2\u8282\u4e86\u3002\n

\n

\n\u6211\u8bf4\uff1a\u201c\u4eca\u5929\u662f\u6bcd\u4eb2\u8282\u554a\uff0c\u4f46\u5988\u5988\u9700\u8981\u53bb\u4e0a\u73ed\u7684\uff1b\u4e0d\u8fc7\u5988\u5988\u4e3a\u4f60\u505a\u597d\u4e86\u86cb\u7cd5\uff0c\u5988\u5988\u662f\u4e0d\u662f\u5f88\u7231\u4f60\u554a\uff1f\u201d\n

\n

\n\u5b69\u5b50\u9ad8\u9ad8\u5174\u5174\u7684\u6d17\u6f31\u4e86\u3002\n

\n

\n\u8fd9\u6bb5\u65f6\u95f4\u56e0\u4e3a\u75ab\u60c5\uff0c\u5e7c\u513f\u56ed\u8fdf\u8fdf\u4e0d\u80fd\u5f00\u5b66\uff0c\u4e00\u76f4\u53ea\u80fd\u5446\u5728\u5bb6\u91cc\u8fc7\u65e0\u6bd4\u6f2b\u957f\u7684\u5bd2\u5047\u3002\n

\n

\n\u5b69\u5b50\u662f\u5f00\u5fc3\u7684\uff0c\u53ef\u4ee5\u6bcf\u5929\u770b\u7535\u89c6\u548c\u75af\u73a9\uff0c\u4f46\u5bb6\u957f\u662f\u5d29\u6e83\u7684\uff0c\u6bd4\u5982\u6211\uff0c\u65e2\u8981\u5728\u5bb6\u91cc\u8fdc\u7a0b\u529e\u516c\uff0c\u8fd8\u8981\u6253\u7406\u5b69\u5b50\u7684\u751f\u6d3b\u8d77\u5c45\u3002\n

\n

\n\u5982\u679c\u5b69\u5b50\u6bd4\u8f83\u542c\u8bdd\u597d\u7ba1\u4e5f\u5c31\u7f62\u4e86\uff0c\u504f\u504f\u81ea\u5df1\u5b69\u5b50\u662f\u4e2a\u4e0d\u670d\u7ba1\u6559\u7684\u8c03\u76ae\u5b69\u5b50\uff0c\u4e00\u5929\u5230\u665a\u60f3\u7740\u770b\u7535\u89c6\uff0c\u4e0d\u7231\u5b66\u4e60\u3002\n

\n

\n\u4f46\u597d\u5728\u5bb6\u91cc\u5c31\u6211\u4e00\u4e2a\u5927\u4eba\uff0c\u53ef\u4ee5\u4e00\u8a00\u5802\uff0c\u4e5f\u53ef\u4ee5\u4e07\u4e8b\u5546\u91cf\u7740\u6765\uff0c\u76ee\u7684\u5c31\u662f\u5728\u81ea\u5df1\u5f97\u7a7a\u7684\u65f6\u5019\uff0c\u6293\u7d27\u4e00\u70b9\u5b69\u5b50\u7684\u5b66\u4e60\u3002\n

\n

\n\u76ee\u524d\u9636\u6bb5\u4e3b\u8981\u662f\u7b80\u5355\u7684\u6570\u5b66\u52a0\u51cf\u6cd5\u548c\u6c49\u5b57\u62fc\u97f3\uff0c\u5176\u5b83\u7684\u4e5f\u5b9e\u5728\u6ca1\u6709\u7cbe\u529b\u548c\u80fd\u529b\u6765\u6559\u4e86\u3002\n

\n

\n\u7167\u4f8b\uff0c\u5403\u5b8c\u5348\u996d\u6211\u51fa\u4e86\u4e00\u5f20\u5c0f\u8bd5\u5377\uff0c\u5305\u542b\u5199\u6570\u5b57\u548c\u52a0\u51cf\u6cd5\uff0c\u5b69\u5b50\u5f88\u4e0d\u60c5\u613f\u7684\u5728\u63a8\u8131\u4e0d\u4e86\u7684\u60c5\u51b5\u4e0b\uff0c\u4e56\u4e56\u5b8c\u6210\u4e86\u3002\n

\n

\n\u770b\u7740\u5199\u7684\u4e03\u626d\u516b\u62d0\u7684\u6570\u5b57\uff0c\u53ea\u80fd\u53f9\u4e00\u53e3\u6c14\uff0c\u8ba9\u4ed6\u81ea\u5df1\u5199\u4e0a\u65e5\u671f\u3001\u59d3\u540d\uff0c\u7136\u540e\u81ea\u5df1\u7ed9\u81ea\u5df1\u6253\u5206\uff0c\u7167\u4f8b\u90fd\u8981\u6253\u4e0a100\u5206\uff0c\u5426\u5219\u5c31\u8981\u54ed\u9f3b\u5b50\u3002\n

\n

\n\u8fd9\u6837\uff0c\u4e00\u5929\u7684\u5b66\u4e60\u5c31\u7b97\u5b8c\u4e86\uff0c\u4f46\u6211\u7684\u6298\u78e8\u624d\u521a\u521a\u5f00\u59cb\u3002\n

\n

\n\u4e09\u56db\u5c81\u7684\u65f6\u5019\u7ed9\u4ed6\u4e70\u4e86\u4e00\u5957\u5927\u82f1\u767e\u79d1\u5168\u4e66\uff0c\u4ed6\u5929\u5929\u7ffb\uff0c\u5404\u79cd\u95ee\uff0c\u83ab\u540d\u5176\u5999\u7684\u5c31\u559c\u6b22\u4e86\u5404\u79cd\u86c7\u3002\n

\n

\n\u4e00\u5929\u5230\u665a\u627e\u673a\u4f1a\u8ba9\u6211\u7ed9\u4ed6\u67e5\u5404\u79cd\u86c7\u7684\u56fe\u7247\u548c\u89c6\u9891\u770b\uff0c\u6bd4\u5982\u53f6\u9f3b\u86c7\u3001\u7b04\u86ed\u3002\n

\n

\n\u5728\u6211\u67e5\u7684\u65f6\u5019\uff0c\u4ed6\u8fd8\u4e00\u526f\u6559\u4e66\u5148\u751f\u7684\u6837\u8bf4\uff1a\u201c\u7b04\u662f\u7af9\u5b57\u5934\u7684\uff0c\u86ed\u662f\u6c34\u86ed\u7684\u86ed\uff0c\u77e5\u9053\u4e86\u6ca1\u6709\uff1f\u201d\n

\n

\n\u628a\u6211\u6c14\u5f97\u8bf4\u4e0d\u51fa\u8bdd\u6765\uff0c\u540e\u6765\u6211\u5c31\u62ff\u4e00\u5f20\u7eb8\uff0c\u5199\u4e0a\u201c\u7b04\u86ed\u201d\u4e24\u4e2a\u5b57\uff0c\u7136\u540e\u5199\u4e0a\u62fc\u97f3\uff1b\u7136\u540e\u544a\u8bc9\u4ed6\uff0c\u4f60\u81ea\u5df1\u53bb\u7535\u8111\u4e0a\u67e5\u3002\n

\n

\n\u4ed6\u5c31\u754f\u754f\u7f29\u7f29\u3001\u53cd\u590d\u786e\u8ba4\u62fc\u97f3\u6ca1\u6253\u9519\u540e\uff0c\u67e5\u5230\u4e00\u4e2a\u201c\u7b04\u86ed\u201d\u5f00\u5fc3\u7684\u4e0d\u5f97\u4e86\u3002\n

\n

\n\u6211\u4e5f\u4e3a\u81ea\u5df1\u7684\u673a\u667a\u6697\u6697\u81ea\u559c\uff0c\u4f46\u540e\u9762\u7684\u70e6\u607c\u968f\u4e4b\u800c\u6765\u3002\n

\n

\n\u6709\u4e00\u6b21\u4ed6\u770b\u4e00\u4e2a\u7ba1\u6c34\u6bcd\u7684\u89c6\u9891\uff0c\u4e0a\u9762\u6709\u4e00\u4e2a\u82f1\u6587\u5355\u8bcd\uff0c\u95ee\u6211\u662f\u4ec0\u4e48\u610f\u601d\u3002\n

\n

\n\u6211\u5fc3\u60f3\u5b69\u5b50\u8fd9\u4e48\u597d\u5b66\uff0c\u8981\u597d\u597d\u5f15\u5bfc\uff0c\u5c31\u7528\u624b\u673a\u6253\u5f00\u8c37\u6b4c\u7ffb\u8bd1\u7684\u7167\u76f8\u7ffb\u8bd1\u529f\u80fd\uff0c\u5bf9\u7167\u89c6\u9891\u4e0a\u7684\u82f1\u6587\u5c31\u81ea\u52a8\u770b\u5230\u7ffb\u8bd1\u4e86\u3002\n

\n

\n\u4f46\u540e\u9762\u4e8b\u6001\u8d85\u51fa\u4e86\u6211\u7684\u9884\u4f30\uff0c\u4ed6\u53c8\u770b\u5230\u5f88\u591a\u89c6\u9891\u91cc\u9762\u7684\u82f1\u6587\u5355\u8bcd\uff0c\u975e\u8981\u6211\u544a\u8bc9\u662f\u4ec0\u4e48\u610f\u601d\uff0c\u4f46\u7ffb\u8bd1\u4e5f\u7ffb\u8bd1\u4e0d\u51fa\u6765\uff0c\u56e0\u4e3a\u662f\u975e\u5e38\u4e13\u4e1a\u7684\u751f\u7269\u672f\u8bed\u5355\u8bcd\u3002\n

\n

\n\u8fd9\u6837\u7684\u4e8b\u60c5\u6bcf\u5929\u5728\u4e0a\u6f14\uff0c\u5b69\u5b50\u6bcf\u5929\u8ba9\u6211\u67e5\u4e1c\u67e5\u897f\uff0c\u4f46\u4ed6\u81ea\u5df1\u7684\u62fc\u97f3\u80fd\u529b\u5374\u5e76\u6ca1\u6709\u4ec0\u4e48\u63d0\u9ad8\uff0c\u6211\u60f3\u662f\u65b9\u6cd5\u4e0d\u5bf9\u3002\n

\n

\n\u4e8e\u662f\uff0c\u6211\u8ddf\u4ed6\u8bf4\uff1a\u201c\u6211\u7ed9\u4f60\u4e70\u4e00\u672c\u5b57\u5178\u597d\u4e0d\u597d\uff0c\u4f60\u60f3\u67e5\u4ec0\u4e48\u4f60\u5c31\u53bb\u4e0a\u9762\u770b\uff0c\u770b\u5230\u62fc\u97f3\u540e\u81ea\u5df1\u5c31\u53ef\u4ee5\u5728\u7535\u8111\u4e0a\u67e5\u4e86\u3002\u201d\n

\n

\n\u4ed6\u6b23\u7136\u7b54\u5e94\u3002\n

\n

\n\u5f88\u5feb\uff0c\u4ed6\u5f97\u5230\u4e86\u4e00\u672c\u5b57\u5178\u3002\n

\n

\n\u770b\u7740\u8fd9\u672c\u5b57\u5178\uff0c\u6211\u60f3\u5230\u4e86\u81ea\u5df1\u7684\u6bcd\u4eb2\uff0c\u5979\u4e5f\u66fe\u7ed9\u6211\u4e70\u8fc7\u4e00\u672c\u5b57\u5178\u3002\n

\n

\n\u90a3\u662f2001\u5e74\uff0c\u4ece\u5c0f\u5b66\u5347\u521d\u4e2d, \u90a3\u5929\u6b63\u597d\u662f\u62a5\u540d\u5f00\u5b66\u7684\u65e5\u5b50\u3002\n

\n

\n\u4ece\u5b66\u6821\u62a5\u5230\u5b8c\u540e\uff0c\u56de\u5bb6\u65f6\u8def\u8fc7\u96c6\u5e02\uff0c\u672c\u60f3\u8bf4\u7ed9\u6211\u4e70\u4ef6\u8863\u670d\u5f00\u5b66\u7a7f\uff0c\u4f46\u770b\u6765\u770b\u53bb\u90fd\u4e0d\u559c\u6b22\u3002\n

\n

\n\u8def\u8fc7\u96c6\u5e02\u8fb9\u4e0a\u7684\u4e2d\u5fc3\u5c0f\u5b66\uff0c\u5c0f\u5b66\u95e8\u53e3\u6709\u4e2a\u8001\u5927\u7237\u6446\u644a\u5356\u4e00\u4e9b\u5b66\u4e60\u8d44\u6599\u548c\u4e66\u7c4d\uff0c\u6211\u770b\u4e2d\u4e86\u4e00\u672c\u65b0\u534e\u5b57\u5178\u3002\n

\n

\n\u7ffb\u4e86\u7ffb\uff0c\u5bf9\u6bcd\u4eb2\u8bf4\uff1a\u201c\u5988\uff0c\u6211\u60f3\u8981\u4e00\u672c\u5b57\u5178\uff01\u201d\n

\n

\n\u6bcd\u4eb2\u770b\u51fa\u4e86\u6211\u60f3\u4e70\u7684\u610f\u601d\uff0c\u95ee\uff1a\u201c\u4f60\u4eec\u4e0a\u5b66\u9700\u8981\u5b57\u5178\u5417\uff1f\u201d\n

\n

\n\u6211\u600f\u600f\u7684\u8bf4\uff1a\u201c\u6709\u5b57\u5178\u5f53\u7136\u597d\uff0c\u53ef\u4ee5\u67e5\u4e00\u4e9b\u4e0d\u8ba4\u8bc6\u7684\u5b57\uff0c\u4f46\u5927\u90e8\u5206\u5b57\u6211\u90fd\u8ba4\u8bc6\u4e86\u3002\u201d\n

\n

\n\u6bcd\u4eb2\u95ee\u4e86\u4ef7\u94b1\uff0c\u662f\u4e94\u5757\u94b1\u4e00\u672c\uff0c\u72b9\u8c6b\u4e86\u4e00\u4e0b\u8fd8\u662f\u4e70\u4e86\u3002\n

\n

\n\u90a3\u672c\u5b57\u5178\u966a\u7740\u6211\u5ea6\u8fc7\u4e86\u521d\u4e2d\u65f6\u671f\u3002\n

\n

\n\u90a3\u65f6\u5019\u4e66\u672c\u4e0a\u5df2\u7ecf\u6709\u4e86\u6587\u8a00\u6587\uff0c\u81ea\u5df1\u4e5f\u770b\u4e86\u5f88\u591a\u5c0f\u8bf4\uff0c\u867d\u7136\u8fd9\u672c\u5b57\u5178\u5e76\u6ca1\u6709\u53d1\u6325\u592a\u5927\u7684\u4f5c\u7528\uff0c\u4f46\u6bcd\u4eb2\u5bf9\u6211\u5b66\u4e60\u7684\u652f\u6301\u5374\u8bb0\u5728\u5fc3\u5934\u3002\n

\n

\n\u65f6\u8fc7\u5883\u8fc1\uff0c\u7269\u662f\u4eba\u975e\uff0c\u90a3\u5df2\u7ecf\u662f\u4e8c\u5341\u5e74\u524d\u7684\u4e8b\u60c5\u4e86\u3002\n

\n

\n\u771f\u6000\u5ff5\u90a3\u4e9b\u53ef\u4ee5\u8131\u53e3\u800c\u51fa\u53eb\u4e00\u58f0\u201c\u5988\u201d\u7684\u5c81\u6708\uff01\n

\n
"}, {"title": "\u79ef\u96e8\u4e91", "url": "/2019/10/17/\u79ef\u96e8\u4e91.html", "content": "
\n

\u79ef\u96e8\u4e91

\n

\n\u65e9\u4e0a\u51fa\u95e8\u7684\u65f6\u5019\uff0c\u5b69\u5b50\u8bf4\u5929\u4e0a\u6709\u6735\u79ef\u96e8\u4e91\uff0c\u9648\u6d01\u6d01\u53ea\u662f\u7b11\u4e00\u7b11\u3002\n

\n

\n\u4f46\u4ece\u5e7c\u513f\u56ed\u95e8\u53e3\u51fa\u6765\u65f6\uff0c\u773c\u770b\u5929\u8272\u6108\u53d1\u4f4e\u6c89\uff0c\u6015\u662f\u4e00\u4f1a\u513f\u771f\u6709\u96e8\uff0c\u5fc3\u91cc\u4e0d\u514d\u6709\u70b9\u62c5\u5fc3\u3002\n

\n

\n\u5b8b\u5f3a\u5750\u5728\u8f66\u91cc\u5e76\u672a\u7184\u706b\uff0c\u9648\u6d01\u6d01\u628a\u5b69\u5b50\u9001\u8fdb\u5e7c\u513f\u56ed\u540e\uff0c\u50cf\u5f80\u5e38\u4e00\u6837\u5750\u4e0a\u8f66\u628a\u63a5\u9001\u5361\u88c5\u5230\u5305\u91cc\u3002\n

\n

\n\u300c\u54ce\uff0c\u4e0d\u662f\u8fd9\u8fb9\uff0c\u6211\u4eca\u5929\u4e0d\u4e0a\u73ed\u554a\uff01\u300d\uff0c\u5b8b\u5f3a\u542f\u52a8\u8f66\u5b50\u521a\u8981\u5f80\u5357\u8d70\uff0c\u9648\u6d01\u6d01\u7b11\u7740\u53eb\u4e86\u8d77\u6765\u3002\n

\n

\n\u5b8b\u5f3a\u53ea\u597d\u62d0\u5f2f\u5411\u5317\uff0c\u53ef\u4e0d\u662f\u561b\uff0c\u6bcf\u5929\u9001\u5b8c\u5b69\u5b50\u4e0a\u5b66\u63a5\u7740\u9001\u5ab3\u5987\u4e0a\u73ed\uff0c\u90fd\u6210\u6761\u4ef6\u53cd\u5c04\u4e86\u3002\n

\n

\n\u4eca\u5929\u9648\u6d01\u6d01\u4e0d\u53bb\u4e0a\u73ed\uff0c\u800c\u662f\u53bb\u4e00\u5bb6\u65b0\u516c\u53f8\u9762\u8bd5\uff0c\u76ee\u524d\u8fd9\u4e2a\u5de5\u4f5c\u5b9e\u5728\u662f\u5e72\u4e0d\u4e0b\u53bb\u4e86\uff0c\u62db\u7684\u65b0\u4eba\u5de5\u8d44\u6bd4\u8001\u5458\u5de5\u9ad8\uff0c\u800c\u8001\u5458\u5de5\u5de5\u8d44\u5374\u6b7b\u6d3b\u4e0d\u6da8\u3002\n

\n

\n\u4e0d\u8fc7\u51e0\u5206\u949f\u5230\u4e86\u5730\u94c1\u53e3\uff0c\u548c\u5b8b\u5f3a\u544a\u522b\u540e\u5750\u4e0a\u4e09\u53f7\u7ebf\u5730\u94c1\u3002\n

\n

\n\u9648\u6d01\u6d01\u60f3\u8d77\u8fd9\u4e00\u5e74\u6765\u7684\u5de5\u4f5c\uff0c\u5bb6\u91cc\u53d1\u751f\u4e86\u5f88\u5927\u7684\u53d8\u5316\uff0c\u592b\u59bb\u5f7c\u6b64\u90fd\u627f\u53d7\u7740\u5f88\u5927\u7684\u538b\u529b\u3002\n

\n

\n\u53c8\u60f3\u8d77\u56e0\u4e3a\u8fd9\u4efd\u5de5\u4f5c\u8001\u662f\u52a0\u73ed\uff0c\u5b8b\u5f3a\u5e38\u5e26\u7740\u5b69\u5b50\u5728\u516c\u53f8\u697c\u5e95\u4e0b\u7b49\u81ea\u5df1\u4e0b\u73ed\uff0c\u800c\u81ea\u5df1\u5374\u8fdf\u8fdf\u65e0\u6cd5\u4e0b\u697c\uff0c\u60f3\u5230\u4ed6\u4eec\u7236\u5b50\u4fe9\u5931\u671b\u800c\u53bb\uff0c\u5fc3\u91cc\u6709\u51e0\u5206\u6127\u759a\u3002\n

\n

\n\u5730\u94c1\u64ad\u62a5\u4e0b\u4e00\u7ad9\u5c31\u662f\u5c0f\u5be8\u4e86\uff0c\u9648\u6d01\u6d01\u5927\u5b66\u5c31\u662f\u5728\u5c0f\u5be8\u9644\u8fd1\u8bfb\u7684\uff0c\u90a3\u91cc\u53d1\u751f\u7684\u6bcf\u4e00\u4ef6\u4e8b\u90fd\u6df1\u6df1\u7684\u5370\u5728\u5979\u7684\u5fc3\u91cc\u3002\n

\n

\n\u9762\u8bd5\u7ecf\u7406\u662f\u4e2a\u4e09\u5341\u6765\u5c81\u7684\u4e2d\u5e74\u4eba\uff0c\u4e00\u8eab\u636f\u996c\u7684\u633a\u6709\u6d3e\u5934\uff0c\u628a\u5979\u7b80\u5386\u53cd\u590d\u7684\u770b\u3002\n

\n

\n\u300c\u54b1\u4eec\u4ee5\u524d\u8ba4\u8bc6\uff0c\u6211\u53eb\u5f20\u660e\u7a0b\uff0c\u8fd8\u8bb0\u5f97\u5417\uff1f\u300d\n

\n

\n\u770b\u9648\u6d01\u6d01\u4e00\u8138\u832b\u7136\uff0c\u5f20\u660e\u7a0b\u5e2e\u7740\u56de\u5fc6\uff1a\u300c\u597d\u51e0\u5e74\u524d\u5427\uff0c\u90a3\u4f1a\u4f60\u521a\u6bd5\u4e1a\uff0c\u53bb\u53c2\u52a0\u4e00\u4e2a\u62db\u8058\u4f1a\u8ba4\u8bc6\u7684\u3002\u300d\n

\n

\n\u9648\u6d01\u6d01\u52aa\u529b\u7684\u60f3\uff0c\u4f46\u8fd8\u662f\u60f3\u4e0d\u8d77\u6765\uff0c\u4f46\u542c\u5230\u5f20\u660e\u7a0b\u8bf4\uff1a\u300c\u90a3\u6b21\uff0c\u6211\u4e0d\u4f46\u8bf7\u4f60\u5403\u996d\uff0c\u6700\u540e\u8fd8\u5f00\u8f66\u9001\u4f60\u53bb\u4f60\u7537\u670b\u53cb\u5b66\u6821\u4e86\uff01\u300d\uff0c\u5979\u5dee\u70b9\u5c16\u53eb\u7ad9\u8d77\u6765\u3002\n

\n

\n\u5979\u7684\u601d\u7eea\u8fc5\u901f\u56de\u5fc6\uff0c\u7684\u786e\u6709\u8fd9\u4e48\u4e00\u56de\u4e8b\u3002\n

\n

\n\u90a3\u65f6\u5927\u5b66\u521a\u6bd5\u4e1a\uff0c\u53bb\u53c2\u52a0\u4e00\u4e2a\u62db\u8058\u4f1a\uff0c\u7136\u540e\u5f20\u660e\u7a0b\u4ee3\u8868\u516c\u53f8\u6765\u62db\u4eba\u3002\n

\n

\n\u672c\u6765\u662f\u8bf4\u8bf4\u8bf4\u7b11\u7b11\uff0c\u540e\u6765\u5230\u4e86\u5348\u996d\u65f6\u95f4\uff0c\u5c31\u4e00\u8d77\u5403\u4e86\u987f\u996d\uff1b\u5403\u996d\u671f\u95f4\uff0c\u95ee\u8d77\u5979\u6709\u6ca1\u6709\u7537\u670b\u53cb\u3002\n

\n

\n\u9648\u6d01\u6d01\u90a3\u65f6\u6b63\u662f\u60c5\u7aa6\u521d\u5f00\u70ed\u604b\u671f\uff0c\u5c31\u5f88\u5f00\u5fc3\u7684\u5206\u4eab\u4e86\u81ea\u5df1\u7684\u5e78\u798f\u7231\u60c5\u751f\u6d3b\u3002\n

\n

\n\u53ef\u80fd\u662f\u5979\u592a\u9ad8\u5174\u4e86\uff0c\u8bf4\u7684\u592a\u5feb\uff0c\u8bf4\u7684\u592a\u591a\uff0c\u8bf4\u7684\u592a\u6295\u5165\uff0c\u8ba9\u5f20\u660e\u7a0b\u89c9\u5f97\u81ea\u5df1\u5e94\u8be5\u544a\u8beb\u4e00\u4e0b\u773c\u524d\u8fd9\u4f4d\u5929\u771f\u7684\u50bb\u59d1\u5a18\u3002\n

\n

\n\u5f20\u660e\u7a0b\u7b49\u5979\u5e73\u9759\u4e0b\u6765\uff0c\u8bf4\uff1a\u300c\u4f60\u73b0\u5728\u8fd8\u592a\u5e74\u8f7b\uff0c\u8fd8\u628a\u7231\u60c5\u770b\u7684\u592a\u91cd\uff0c\u6211\u544a\u8bc9\u4f60\uff0c\u7231\u60c5\u9760\u4e0d\u4f4f\uff01\u300d\n

\n

\n\u300c\u4f60\u4e5f\u6ca1\u6bd4\u6211\u5927\u51e0\u5c81\u554a\uff0c\u600e\u4e48\u7231\u60c5\u5c31\u9760\u4e0d\u4f4f\uff0c\u6211\u76f8\u4fe1\u6211\u7537\u670b\u53cb\u3002\u300d\uff0c\u9648\u6d01\u6d01\u89c9\u5f97\u5bf9\u65b9\u8bf4\u8fd9\u6837\u7684\u8bdd\u5f88\u6ca1\u6709\u793c\u8c8c\u3002\n

\n

\n\u5f20\u660e\u7a0b\u7b11\u7740\u8bf4\uff1a\u300c\u6709\u53e5\u8bdd\u600e\u4e48\u8bf4\u6765\u7740\uff0c\u6bd5\u4e1a\u5c31\u5206\u624b\uff01\u300d\n

\n

\n\u770b\u9648\u6d01\u6d01\u6ca1\u6709\u8bf4\u8bdd\uff0c\u4ed6\u63a5\u7740\u53d1\u51fa\u81ea\u5df1\u7684\u5fe0\u544a\uff1a\u300c\u8fd9\u7537\u4eba\u554a\uff0c\u51fa\u4e86\u793e\u4f1a\u4ee5\u540e\u8bf1\u60d1\u592a\u591a\u4e86\uff0c\u8c01\u8fd8\u770b\u91cd\u7231\u60c5\u554a\u3002\u300d\n

\n

\n\u9648\u6d01\u6d01\u65e0\u529b\u7684\u53cd\u9a73\u5230\uff1a\u300c\u53cd\u6b63\u6211\u76f8\u4fe1\u6211\u7537\u670b\u53cb\u3002\u300d\n

\n

\n\u300c\u5728\u751f\u610f\u573a\u4e0a\u6df7\uff0c\u8fd9\u6837\u7684\u6211\u89c1\u591a\u4e86\uff0c\u4fe1\u4e0d\u4fe1\u6211\u53eb\u6211\u516c\u53f8\u7684\u5973\u516c\u5173\uff0c\u4e00\u5929\u628a\u4f60\u7537\u670b\u53cb\u62ff\u4e0b\uff0c\u6562\u4e0d\u6562\u8bd5\u8bd5\uff1f\u300d\n

\n

\n\u9648\u6d01\u6d01\u89c9\u5f97\u81ea\u5df1\u8be5\u8d70\u4e86\uff0c\u771f\u4e0d\u5e94\u8be5\u5403\u8fd9\u987f\u996d\uff0c\u542c\u8fd9\u4e9b\u6df7\u8d26\u8bdd\u3002\n

\n

\n\u51fa\u4e86\u996d\u5e97\uff0c\u5916\u9762\u5374\u5df2\u7ecf\u662f\u6fdb\u6fdb\u7ec6\u96e8\uff0c\u5f20\u660e\u7a0b\u8ddf\u51fa\u6765\u8bf4\uff0c\u5e72\u8106\u4ed6\u5f00\u8f66\u9001\u4e00\u6bb5\u3002\n

\n

\n\u5f53\u77e5\u9053\u9648\u6d01\u6d01\u662f\u8981\u53bb\u7537\u670b\u53cb\u5b66\u6821\u65f6\uff0c\u5f20\u660e\u7a0b\u89c9\u5f97\u8fd9\u8d9f\u975e\u9001\u4e0d\u53ef\u4e86\u3002\n

\n

\n\u4e00\u8def\u4e0a\u5f20\u660e\u7a0b\u770b\u9648\u6d01\u6d01\u6709\u70b9\u751f\u6c14\uff0c\u5fd9\u9053\u6b49\u7684\u8bf4\uff1a\n

\n

\n\u300c\u5176\u5b9e\u6211\u521a\u624d\u8bf4\u90a3\u756a\u8bdd\u6ca1\u6709\u6076\u610f\uff0c\u6211\u4e00\u770b\u4f60\u5c31\u50cf\u81ea\u5df1\u7684\u8868\u59b9\u4e00\u6837\uff0c\u662f\u6015\u4f60\u5728\u611f\u60c5\u4e16\u754c\u91cc\u9677\u5f97\u592a\u6df1\u53d7\u4f24\u5bb3\u3002\u300d\n

\n

\n\u5927\u5b66\u57ce\u8fd9\u8fb9\u5012\u6ca1\u6709\u4e0b\u96e8\uff0c\u8f66\u5b50\u505c\u5230\u5b8b\u5f3a\u5b66\u6821\u95e8\u53e3\uff0c\u9648\u6d01\u6d01\u5fc3\u60c5\u597d\u4e86\u4e0d\u5c11\uff0c\u60f3\u7740\u4e0d\u7ba1\u600e\u6837\uff0c\u4eba\u5bb6\u9001\u4e86\u81ea\u5df1\u4e00\u8d9f\uff0c\u8fd8\u662f\u7b11\u7740\u611f\u8c22\u4e86\u5f20\u660e\u7a0b\u3002\n

\n

\n\u8fd9\u6b21\u9648\u6d01\u6d01\u6765\u627e\u5b8b\u5f3a\u4e5f\u662f\u4e34\u65f6\u8d77\u610f\uff0c\u53ef\u80fd\u662f\u5f20\u660e\u7a0b\u8bf4\u7684\u90a3\u756a\u8bdd\u8ba9\u5979\u5fc3\u91cc\u5835\u7684\u614c\uff0c\u53ea\u6709\u548c\u5b8b\u5f3a\u89c1\u4e00\u9762\u597d\u597d\u804a\u804a\uff0c\u5979\u624d\u80fd\u5fc3\u5b89\u3002\n

\n

\n\u5b8b\u5f3a\u6765\u5230\u5b66\u6821\u56fe\u4e66\u9986\u5916\uff0c\u89c1\u9648\u6d01\u6d01\u4f2b\u7acb\u5728\u82b1\u575b\u8fb9\u62db\u624b\uff0c\u5e76\u672a\u8868\u73b0\u7684\u6709\u591a\u4e48\u559c\u60a6\uff0c\u4ed6\u6b63\u4e3a\u81ea\u5df1\u88ab\u6253\u6270\u800c\u4e0d\u5feb\u3002\n

\n

\n\u4ed6\u662f\u5982\u6b64\u51b7\u51b0\u51b0\uff0c\u9648\u6d01\u6d01\u53ea\u597d\u5f00\u53e3\u8bf4\uff1a\u300c\u4f60\u731c\u731c\u4eca\u5929\u6211\u600e\u4e48\u8fc7\u6765\u7684\uff1f\u300d\n

\n

\n\u300c\u6211\u731c\u4e0d\u7740\uff0c\u5750\u516c\u4ea4\u8f66\u5457\uff0c\u8fd8\u80fd\u600e\u4e48\u8fc7\u6765\u300d\n

\n

\n\u300c\u4e0d\u662f\uff0c\u4f60\u80af\u5b9a\u731c\u4e0d\u51fa\u6765\uff0c\u662f\u522b\u4eba\u5f00\u8f66\u9001\u6211\u8fc7\u6765\u7684\u3002\u300d\uff0c\u770b\u7740\u5b8b\u5f3a\u72d0\u7591\u7684\u773c\u795e\uff0c\u9648\u6d01\u6d01\u4e00\u8138\u5174\u594b\u3002\n

\n

\n\u300c\u6211\u4eca\u5929\u53bb\u53c2\u52a0\u62db\u8058\u4f1a\u8ba4\u8bc6\u7684\uff0c\u4ed6\u8bf7\u6211\u5403\u4e86\u987f\u996d\uff0c\u8fd8\u8bf4\u6211\u50cf\u4ed6\u8868\u59b9\uff0c\u4e00\u89c1\u6211\u5c31\u60f3\u5e26\u6211\u56de\u5bb6\u4e0b\u9762\u7ed9\u6211\u5403\u5462\uff0c\u54c8\u54c8\u300d\n

\n

\n\u5b8b\u5f3a\u89c9\u5f97\u4e0d\u53ef\u601d\u8bae\uff0c\u5979\u7adf\u7136\u4f1a\u8fd9\u6837\u968f\u968f\u4fbf\u4fbf\u548c\u964c\u751f\u4eba\u5403\u996d\uff0c\u8fd8\u8fd9\u6837\u4e00\u8138\u5f97\u610f\u7684\u8bf4\u51fa\u6765\u3002\n

\n

\n\u300c\u4ed6\u529d\u544a\u8bf4\u7231\u60c5\u9760\u4e0d\u4f4f\uff0c\u4e0d\u8981\u9677\u5f97\u592a\u6df1\uff0c\u4e0d\u7136\u6700\u7ec8\u53d7\u4f24\u7684\u8fd8\u662f\u81ea\u5df1\u3002\u300d\n

\n

\n\u5b8b\u5f3a\u6709\u70b9\u6012\u4e86\uff1a\u300c\u4ed6\u8c01\u554a\uff1f\u65e2\u7136\u7231\u60c5\u9760\u4e0d\u4f4f\uff0c\u4f60\u8fd8\u6765\u627e\u6211\u5e72\u4ec0\u4e48\uff1f\u300d\n

\n

\n\u9648\u6d01\u6d01\u89c9\u5f97\u83ab\u540d\u5176\u5999\uff0c\u8fd9\u6709\u4ec0\u4e48\u597d\u751f\u6c14\u7684\uff0c\u751a\u81f3\u89c9\u5f97\u6709\u70b9\u59d4\u5c48\uff0c\u8d76\u5fd9\u8bf4\uff1a\u300c\u6211\u5f53\u65f6\u5c31\u53cd\u9a73\u4ed6\u4e86\uff0c\u6211\u8bf4\u6211\u76f8\u4fe1\u6211\u7537\u670b\u53cb\uff01\u300d\n

\n

\n\u5b8b\u5f3a\u6ca1\u597d\u6c14\u7684\u7528\u9f3b\u5b54\u54fc\u4e86\u4e00\u58f0\uff0c\u8868\u793a\u542c\u89c1\u4e86\u3002\n

\n

\n\u300c\u4ed6\u8fd8\u8bf4\uff0c\u6d3e\u516c\u53f8\u7684\u5973\u516c\u5173\u6765\uff0c\u4e00\u5929\u5c31\u53ef\u4ee5\u628a\u4f60\u62ff\u4e0b\u3002\u6211\u53ea\u544a\u8bc9\u4ed6\uff0c\u4e0d\u9700\u8981\u6d3e\u8c01\uff0c\u53cd\u6b63\u6211\u76f8\u4fe1\u6211\u7537\u670b\u53cb\uff01\u300d\n

\n

\n\u9648\u6d01\u6d01\u770b\u5b8b\u5f3a\u8fd8\u6709\u70b9\u751f\u6c14\uff0c\u4f46\u8138\u8272\u5df2\u7ecf\u7f13\u548c\u5f88\u591a\u4e86\uff0c\u4f9d\u504e\u5728\u4ed6\u80a9\u8180\u4e0a\uff0c\u67d4\u58f0\u8bf4\uff1a\u300c\u6211\u4ee5\u540e\u4e0d\u8ddf\u8fd9\u79cd\u4eba\u8bf4\u8bdd\u4e86\uff0c\u539f\u8c05\u6211\u6d89\u4e16\u672a\u6df1\uff01\u300d\n

\n

\n\u4f46\u5b8b\u5f3a\u611f\u89c9\u53d7\u5230\u4e86\u4fae\u8fb1\uff0c\u51b7\u51b7\u7684\u8bf4\uff0c\u300c\u5176\u5b9e\u4f60\u53ef\u4ee5\u8ba9\u4ed6\u6d3e\u5973\u516c\u5173\u6765\uff0c\u770b\u80fd\u4e0d\u80fd\u628a\u6211\u62ff\u4e0b\uff1f\u300d\n

\n

\n\u9648\u6d01\u6d01\u5fd9\u6469\u6332\u7740\u5b8b\u5f3a\u7684\u80cc\u90e8\uff0c\u7740\u6025\u7684\u8fa9\u89e3\uff1a\u300c\u54ce\u5440\uff0c\u4e0d\u751f\u6c14\u4e86\u561b\uff0c\u8fd9\u6b21\u662f\u6211\u4e0d\u5bf9\uff0c\u6211\u4e0d\u8be5\u5750\u4ed6\u7684\u8f66\uff0c\u542c\u4ed6\u8bf4\u8fd9\u4e9b\u6df7\u8d26\u8bdd\u3002\u300d\n

\n

\n\u5b8b\u5f3a\u5374\u4e0d\u4f9d\u4e0d\u9976\uff1a\u300c\u4e8b\u60c5\u505a\u4e86\u5c31\u7b97\u4e86\uff0c\u4f60\u8fd8\u597d\u610f\u601d\u606c\u7740\u8138\u7ed9\u6211\u8bf4\uff0c\u4ec0\u4e48\u5e26\u4f60\u56de\u5bb6\u4e0b\u9762\u5403\uff0c\u4f60\u77e5\u9053\u4ed6\u5728\u5360\u4f60\u4fbf\u5b9c\u5417\uff1f\u300d\n

\n

\n\u300c\u4ec0\u4e48\u5360\u6211\u4fbf\u5b9c\uff1f\u5317\u65b9\u5403\u9762\u5f88\u6b63\u5e38\u554a\uff0c\u5bb6\u91cc\u505a\u987f\u9762\u62db\u5f85\u5ba2\u4eba\u624d\u91cd\u89c6\u554a\uff1f\u300d\uff0c\u9648\u6d01\u6d01\u6025\u7684\u8981\u54ed\u4e86\u3002\n

\n

\n\u300c\u54ce\uff0c\u6211\u600e\u4e48\u548c\u4f60\u8bf4\u5462\uff0c\u7b97\u4e86\uff0c\u6211\u4eec\u5206\u624b\u5427\uff01\u5b9e\u5728\u60f3\u4e0d\u5230\uff0c\u8fd9\u5929\u5e95\u4e0b\u8fd8\u6709\u8fd9\u4e48\u7b28\u7684\u5973\u4eba\u3002\u300d\n

\n

\n\u5b8b\u5f3a\u8fd9\u53e5\u8bdd\u4eff\u4f5b\u662f\u9a8c\u8bc1\u4e86\u5f20\u660e\u7a0b\u7684\u8bdd\uff0c\u9648\u6d01\u6d01\u7b80\u76f4\u4e0d\u613f\u76f8\u4fe1\u81ea\u5df1\u7684\u8033\u6735\uff0c\u8f6c\u8eab\u671d\u6821\u95e8\u53e3\u8d70\u53bb\uff0c\u773c\u6cea\u60c5\u4e0d\u81ea\u7981\u7684\u6d41\u4e0b\u6765\u3002\n

\n

\n\u770b\u9648\u6d01\u6d01\u8fb9\u8d70\u8fb9\u54ed\uff0c\u5b8b\u5f3a\u5012\u89c9\u5f97\u81ea\u5df1\u505a\u7684\u6709\u70b9\u592a\u8fc7\u4e86\uff0c\u5c31\u62c9\u4e86\u62c9\u9648\u6d01\u6d01\u7684\u624b\uff0c\u300c\u5c31\u56de\u53bb\u4e86\uff1f\u8981\u4e0d\u5403\u5b8c\u996d\u518d\u56de\u53bb\u5427\uff1f\u300d\n

\n

\n\u9648\u6d01\u6d01\u7529\u5f00\uff0c\u6ca1\u597d\u6c14\u7684\u8bf4\uff0c\u300c\u90fd\u5206\u624b\u4e86\uff0c\u8fd8\u5403\u4ec0\u4e48\u996d\uff1f\u300d\n

\n

\n\u5c31\u8fd9\u6837\uff0c\u5b8b\u5f3a\u8ddf\u7740\u8d70\u51fa\u6821\u95e8\u53e3\uff0c\u76ee\u9001\u9648\u6d01\u6d01\u5750\u4e0a\u516c\u4ea4\u8f66\uff0c\u7136\u540e\u5782\u5934\u4e27\u6c14\u7684\u56de\u5230\u56fe\u4e66\u9986\u3002\n

\n

\n\u300c\u524d\u4e00\u79d2\u5728\u5929\u5802\uff0c\u540e\u4e00\u79d2\u5728\u5730\u72f1\u3002\u300d\n

\n

\n\u8fd9\u662f\u9648\u6d01\u6d01\u5f53\u665a\u53d1\u7ed9\u5b8b\u5f3a\u7684\u77ed\u4fe1\uff0c\u5b8b\u5f3a\u6ca1\u56de\uff0c\u7b49\u5230\u51cc\u6668\u624d\u56de\u4e86\u4e00\u53e5\uff1a\u300c\u660e\u5929\u6211\u6765\u627e\u4f60\u5427\u300d\u3002\n

\n

\n\u9648\u6d01\u6d01\u5f88\u5feb\u56de\u590d\u4e86\u4e00\u4e2a\u5b57\uff1a\u300c\u597d\u300d\u3002\n

\n

\n\u4e24\u4eba\u5f88\u5feb\u548c\u597d\uff0c\u540e\u6765\u5171\u540c\u7ec4\u5efa\u4e86\u5bb6\u5ead\uff0c\u8bf4\u8d77\u8fd9\u4e2a\u4e8b\u60c5\uff0c\u4e24\u4eba\u90fd\u5f53\u505a\u4e00\u4ef6\u7b11\u8c08\uff0c\u4e3a\u5f7c\u6b64\u5f53\u5e74\u7684\u4e3e\u6b62\u611f\u5230\u597d\u7b11\u3002\n

\n

\n\u8fd9\u4ef6\u4e8b\u60c5\u9010\u6e10\u6de1\u5fd8\u4e86\uff0c\u6240\u4ee5\u5f53\u9648\u6d01\u6d01\u8ba4\u51fa\u773c\u524d\u8fd9\u4e2a\u9762\u8bd5\u81ea\u5df1\u7684\u4eba\u5c31\u662f\u5f53\u5e74\u7684\u5f20\u660e\u7a0b\u65f6\uff0c\u5979\u4e0d\u77e5\u9053\u8be5\u8bf4\u4ec0\u4e48\u3002\n

\n

\n\u5f20\u660e\u7a0b\u7b11\u7740\u8bf4\uff1a\u300c\u600e\u4e48\u6837\uff1f\u4f60\u7684\u7231\u60c5\u7ecf\u53d7\u4f4f\u4e86\u8003\u9a8c\u5417\uff1f\u300d\n

\n

\n\u9648\u6d01\u6d01\u660e\u767d\u4ed6\u7684\u610f\u601d\uff0c\u7406\u4e86\u7406\u5934\u53d1\uff0c\u5f88\u9a84\u50b2\u7684\u8bf4\uff1a\u300c\u6211\u7684\u7231\u60c5\u4e0d\u4f46\u7ecf\u53d7\u4f4f\u4e86\u8003\u9a8c\uff0c\u8fd8\u5f00\u82b1\u7ed3\u679c\u4e86\uff0c\u5b69\u5b50\u90fd\u4e0a\u5b66\u4e86\uff01\u300d\n

\n

\n\u6709\u4e86\u4ee5\u524d\u7684\u4e8b\u60c5\uff0c\u9648\u6d01\u6d01\u6ca1\u6709\u548c\u5f20\u660e\u7a0b\u592a\u591a\u7ea0\u7f20\uff0c\u5306\u5306\u56de\u7b54\u4e86\u51e0\u4e2a\u95ee\u9898\u5c31\u79bb\u5f00\u4e86\uff0c\u5e76\u4e14\u51b3\u5b9a\u81ea\u5df1\u4e0d\u4f1a\u6765\u8fd9\u5bb6\u516c\u53f8\u4e0a\u73ed\u3002\n

\n

\n\u5b8b\u5f3a\u6b63\u5750\u5728\u4e00\u4e2a\u89d2\u843d\u559d\u80e1\u8fa3\u6c64\uff0c\u6bcf\u5929\u9001\u5b8c\u8001\u5a46\u5b69\u5b50\u540e\uff0c\u4ed6\u90fd\u5728\u8fd9\u5bb6\u5c0f\u5e97\u5403\u65e9\u9910\u3002\n

\n

\n\u9648\u6d01\u6d01\u53d1\u6765\u4fe1\u606f\uff0c\u8bf4\u5df2\u7ecf\u5750\u4e0a\u56de\u6765\u7684\u5730\u94c1\u4e86\uff0c\u8ba9\u53bb\u5730\u94c1\u53e3\u63a5\u5979\u3002\n

\n

\n\u5b8b\u5f3a\u5fc3\u60f3\u867d\u7136\u81ea\u5df1\u8fb9\u73a9\u624b\u673a\u8fb9\u5403\u996d\uff0c\u7684\u786e\u6709\u70b9\u6162\uff0c\u4f46\u5979\u4e5f\u56de\u6765\u7684\u592a\u5feb\u4e86\u5427\uff0c\u96be\u9053\u9762\u8bd5\u4e0d\u987a\u5229\uff1f\n

\n

\n\u9648\u6d01\u6d01\u770b\u8d77\u6765\u5fc3\u60c5\u4e0d\u9519\uff0c\u5750\u4e0a\u8f66\u5c31\u628a\u5e7f\u64ad\u5173\u4e86\uff0c\u7528\u624b\u673a\u64ad\u653e\u4e86\u97f3\u4e50\uff0c\u662f\u300a\u96ea\u5c71\u98de\u72d0\u300b\u7684\u4e3b\u9898\u66f2\u300a\u96ea\u4e2d\u60c5\u300b\u3002\n

\n

\n\u5b8b\u5f3a\u6545\u4f5c\u8f7b\u677e\u7684\u95ee\uff1a\u300c\u600e\u4e48\uff1f\u8fd9\u4e48\u5feb\u5c31\u9762\u8bd5\u5b8c\u4e86\uff1f\u300d\n

\n

\n\u9648\u6d01\u6d01\u6ca1\u597d\u6c14\u7684\u8bf4\uff1a\u300c\u54ce\uff0c\u5c31\u662f\u4e00\u4e2a\u5c0f\u516c\u53f8\uff0c\u5173\u952e\u90a3\u9762\u8bd5\u5b98\u8d3c\u7709\u9f20\u773c\uff0c\u4e00\u770b\u5c31\u70e6\u3002\u300d\n

\n

\n\u5b8b\u5f3a\u54c8\u54c8\u4e00\u7b11\uff0c\u95ee\uff1a\u300c\u4f60\u77e5\u9053\u6211\u6bcf\u5929\u5403\u65e9\u9910\u90a3\u4e2a\u8001\u677f\u5a18\u53eb\u4ec0\u4e48\u540d\u5b57\u5417\uff1f\u300d\n

\n

\n\u300c\u53eb\u5565\u540d\u5b57\uff1f\u300d\n

\n

\n\u300c\u7f57\u8273\u8273\u300d\n

\n

\n\u300c\u71d5\u5b50\u7684\u71d5\uff1f\u300d\n

\n

\n\u300c\u7f8e\u8273\u7684\u8273\uff0c\u54c8\u54c8\u3002\u3002\u3002\u300d\n

\n

\n\u8f66\u5b50\u4e00\u8def\u5411\u5357\u75be\u9a70\uff0c\u9648\u6d01\u6d01\u770b\u7a97\u5916\u4e91\u6de1\u98ce\u8f7b\uff0c\u65e9\u4e0a\u90a3\u56e2\u79ef\u96e8\u4e91\u65e9\u5df2\u4e0d\u77e5\u53bb\u5411\u3002\n

\n

\n\u53ef\u89c1\uff0c\u5373\u4f7f\u770b\u89c1\u79ef\u96e8\u4e91\uff0c\u4e5f\u672a\u5fc5\u4f1a\u6709\u96e8\u3002\n

\n
"}, {"title": "\u51e0\u4e2a\u5e38\u7528\u7684Linux\u547d\u4ee4\u4e0e\u95ee\u9898", "url": "/2022/10/18/unzip.html", "content": "None"}, {"title": "\u7b2c\u4e00\u4f4d\u7530\u56ed\u8bd7\u4eba\u9676\u6e0a\u660e", "url": "/2022/10/18/NanChaoGuShiRenWu_01.html", "content": "None"}, {"title": "\u5510\u7384\u5b97\u5728\u4f4d45\u5e74\u5927\u4e8b\u8bb0", "url": "/2022/06/22/TangXuanZong.html", "content": "None"}, {"title": "\u5510\u9ad8\u5b97\u5eb6\u957f\u5b50\u674e\u5fe0\u7684\u574e\u5777\u4eba\u751f", "url": "/2022/06/20/LiZhong.html", "content": "None"}, {"title": "\u5510\u671d\u768420\u4f4d\u7687\u5e1d", "url": "/2022/06/19/TangChaoHuangDiJieShao.html", "content": "None"}, {"title": "\u8bd7\u4eba\u5d14\u98a2\u7684\u6709\u6587\u65e0\u884c", "url": "/2022/05/19/CuiHao.html", "content": "None"}] +[{"title": "\u5c0f\u4eba\u9769\u9762\uff0c\u541b\u5b50\u8c79\u53d8", "url": "/2023/08/01/junzibaobian.html", "content": "None"}, {"title": "\u5f02\u4e61\u6709\u609f\uff1a\u4e94\u4e00\u5047\u671f\u9655\u5317\u81ea\u9a7e\u6e38", "url": "/2023/07/04/travel_202351.html", "content": "None"}, {"title": "\u6e56\u8fb9\u7684\u83ab\u6101\u5973", "url": "/2023/05/31/hu_bian_de_mo_chou_nv.html", "content": "None"}, {"title": "\u5357\u5317\u671d\u4eba\u7269\u4e4b\u9634\u94ff", "url": "/2023/04/13/yin_keng.html", "content": "None"}, {"title": "\u65e5\u8bed\u5165\u95e8\u9636\u6bb5\u4f8b\u53e5\u6574\u7406", "url": "/2023/03/23/learn_japanese_4.html", "content": "None"}, {"title": "FaceSwap\u8fdb\u884c\u89c6\u9891AI\u6362\u8138", "url": "/2023/03/15/faceswap_1.html", "content": "None"}, {"title": "Windows\u4f7f\u7528Stable Diffusion\u8fdb\u884cAI\u753b\u56fe(GPU)", "url": "/2023/03/14/use_StableDiffusion_gen_photo_with_gpu_on_windows.html", "content": "None"}, {"title": "Mac\u4f7f\u7528Stable Diffusion\u8fdb\u884cAI\u753b\u56fe(CPU)", "url": "/2023/03/03/use_StableDiffusion_gen_photo.html", "content": "None"}, {"title": "CStdString:\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684\u5b57\u7b26\u4e32\u7c7b\u5b9e\u73b0", "url": "/2019/12/29/about_CStdString.html", "content": "None"}, {"title": "CMake\u4f7f\u7528Doxygen\u81ea\u52a8\u751f\u6210\u6587\u6863", "url": "/2023/03/01/doxygen_work_with_cmake.html", "content": "None"}, {"title": "\u4f7f\u7528shred\u5de5\u5177\u5f7b\u5e95\u7c89\u788e\u6587\u4ef6", "url": "/2022/11/12/delete_file_with_shred.html", "content": "None"}, {"title": "\u706b\u628a\u9f99", "url": "/2022/12/29/torch_dragon.html", "content": "None"}, {"title": "TensorFlow\u8bfb\u53d6.pb\u6a21\u578b\u6587\u4ef6\u5e76\u9884\u6d4b\u56fe\u7247", "url": "/2023/02/03/tensorflow_2.html", "content": "None"}, {"title": "\u6e90\u7801\u7f16\u8bd1TensorFlow\u4e3aC++ API\u52a8\u6001\u5e93", "url": "/2019/08/29/tensorflow_1.html", "content": "None"}, {"title": "Protocol Buffers:\u8c37\u6b4c\u5f00\u6e90\u7684\u6570\u636e\u4ea4\u6362\u683c\u5f0f\u534f\u8bae", "url": "/2023/01/31/protobuf.html", "content": "None"}, {"title": "\u5236\u4f5crpm\u5b89\u88c5\u5305\u6587\u4ef6", "url": "/2022/10/24/yum_rpm.html", "content": "
\n

\u5236\u4f5crpm\u5b89\u88c5\u5305\u6587\u4ef6

\n\n
\n

1. \u5236\u4f5crpm\u6587\u4ef6

\n
\n

\n\u8fd9\u91cc\u5047\u8bbe\u6709\u4e00\u4e9b\u4e8c\u8fdb\u5236\u6587\u4ef6\u548c\u76f8\u5173Shell\u811a\u672c\uff0c\u60f3\u6253\u5305\u4e3arpm\u683c\u5f0f\u5b9e\u73b0\u4e00\u952e\u81ea\u52a8\u5b89\u88c5\u3002\n

\n
    \n
  • \u5b89\u88c5\u5de5\u5177\u5305
  • \n
\n
\n$ sudo yum install rpm-build rpmdevtools\n
\n
    \n
  • \u521b\u5efa\u5de5\u4f5c\u76ee\u5f55
  • \n
\n
\n$ rpmdev-setuptree  # \u9ed8\u8ba4\u521b\u5efa~/rpmbuild/\n\n$ tree ~/rpmbuild/\n\n~/rpmbuild/\n\u251c\u2500\u2500 BUILD\n\u251c\u2500\u2500 BUILDROOT\n\u251c\u2500\u2500 RPMS\n\u251c\u2500\u2500 SOURCES\n\u251c\u2500\u2500 SPECS\n\u2514\u2500\u2500 SRPMS\n
\n

\n\u5982\u679c\u66f4\u6539\u4e00\u4e9b\u9ed8\u8ba4\u8bbe\u7f6e\uff0c\u76f4\u63a5\u4fee\u6539\u6587\u4ef6 ~/.rpmmacros:\n

\n
\n%_topdir %(echo $HOME)/rpmbuild\n\n%_smp_mflags %( \\\n    [ -z \"$RPM_BUILD_NCPUS\" ] \\\\\\\n        && RPM_BUILD_NCPUS=\"`/usr/bin/nproc 2>/dev/null || \\\\\\\n                             /usr/bin/getconf _NPROCESSORS_ONLN`\"; \\\\\\\n    if [ \"$RPM_BUILD_NCPUS\" -gt 16 ]; then \\\\\\\n        echo \"-j16\"; \\\\\\\n    elif [ \"$RPM_BUILD_NCPUS\" -gt 3 ]; then \\\\\\\n        echo \"-j$RPM_BUILD_NCPUS\"; \\\\\\\n    else \\\\\\\n        echo \"-j3\"; \\\\\\\n    fi )\n\n%__arch_install_post \\\n    [ \"%{buildarch}\" = \"noarch\" ] || QA_CHECK_RPATHS=1 ; \\\n    case \"${QA_CHECK_RPATHS:-}\" in [1yY]*) /usr/lib/rpm/check-rpaths ;; esac \\\n    /usr/lib/rpm/check-buildroot\n
\n
\n
\n

1.1. \u51c6\u5907\u8f6f\u4ef6\u6e90\u6587\u4ef6

\n
\n
\n$ tree ~/rpmbuild/SOURCES/\n\n~/rpmbuild/SOURCES/\n\u251c\u2500\u2500 test-1.0.0\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 Makefile\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test.exe\n\u2514\u2500\u2500 test-1.0.0.tar.gz\n
\n

\n\u4e3b\u8981\u6587\u4ef6\u662f ~/rpmbuild/SOURCES/test-1.0.0/Makefile \u89c4\u5b9a\u4e86\u5982\u4f55\u6267\u884c\u5b89\u88c5\u6b65\u9aa4:\n

\n
\n
ifdef DESTDIR\n        destDir=$(DESTDIR)/usr/local/Test/bin\nelse\n        destDir=~/Test/bin\nendif\n\ninstall: test.exe\n        test -d $(destDir) || mkdir -p $(destDir)\n        cp test.exe $(destDir)/test.exe\n\n.PHONY: clean\n\nclean:\n        rm -f $(destDir)/test.exe\n
\n
\n

\n\u4e4b\u540e\u5c06\u8f6f\u4ef6\u6e90\u6587\u4ef6\u76ee\u5f55\u6253\u5305\u4e3a *.tar.gz \u683c\u5f0f\u6587\u4ef6\u3002\n

\n
\n
\n
\n

1.2. \u521b\u5efaSPEC\u6587\u4ef6

\n
\n

\n\u4f7f\u7528 vim \u6253\u5f00 *.spec \u540e\u7f00\u6587\u4ef6\u65f6\u4f1a\u81ea\u52a8\u52a0\u8f7d\u6a21\u677f\uff0c\u6e90\u81ea\u4e8e\u8bfb\u53d6\u4e86\u6a21\u677f\u6587\u4ef6 /usr/share/vim/vimfiles/template.spec.\n

\n

\n\u5982\u679c\u81ea\u5df1\u8981\u6dfb\u52a0\u65b0\u6a21\u677f\u5219:\n

\n
\n$ vim /etc/vimrc\n\nautocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec  # \u81ea\u5e26\u7684\u6a21\u677f\u89c4\u5219\nautocmd BufNewFile *.test 0r /usr/share/vim/vimfiles/template.test  # \u81ea\u5b9a\u4e49\u7684\u65b0\u589e\u6a21\u677f\u89c4\u5219\n
\n

\n~/rpmbuild/SPECS/test.spec \u5185\u5bb9:\n

\n
\n#\n# \u4ee5#\u7b26\u53f7\u5f00\u5934\u7684\u884c\u662f\u6ce8\u91ca\u884c\n# 2022-10-21\n# Author: LeslieZhu\n\n# \u4f1a\u521b\u5efa\u76ee\u5f55: rpmbuild/BUILDROOT/%%(name)-%%(version)-%%(release).%%(arch)\nName:\t test\n\n# \u7248\u672c\u53f7\nVersion: 1.0.0\n\n# \u53d1\u5e03\u6b21\u6570\nRelease: 2\n\nSummary: A Test Program\n\nGroup: TestTeam\n\nLicense: GPLv3\n\n# N/A: \u8868\u793a\u6ca1\u6709\nURL: N/A\n\n# \u6784\u5efa\u76ee\u6807\u67b6\u6784\nBuildArch: x86_64\n\n# \u7528\u6765\u6784\u5efaRPM\u6587\u4ef6\u7684\u6e90\u6587\u4ef6,\u5982\u679c\u4e0d\u63d0\u4f9b\u5219\u4f7f\u7528\u4e0b\u65b9\u7684%files\nSource0: %{name}-%{version}.tar.gz\n\n# \u6784\u5efa\u7684\u65f6\u5019\u4f9d\u8d56\u7684\u8f6f\u4ef6\u5305\nBuildRequires: gcc,vim\n\n# \u8f6f\u4ef6\u8fd0\u884c\u65f6\u9700\u8981\u7684\u8f6f\u4ef6\u5305\nRequires: gcc,vim\n\n%description\n\nThis is a test program.\n\n# \u6d4b\u8bd5\u5b89\u88c5\u76ee\u5f55\nBuildRoot: %_topdir/BUILDROOT\n\n# \u6784\u5efa\u8f6f\u4ef6\u5305\u4e4b\u524d\u8981\u505a\u7684\u4e8b\u60c5\n%prep\n\n# \u89e3\u538b\u5e76cd,\u5c06%_sourcedir\u5185\u5bb9\u89e3\u538b\u5230%_builddir\n%setup -q\n\n\n%build\n# \u5982\u679c\u6709\u6e90\u7801\u7f16\u8bd1\u5219\u4e00\u822c\u662f ./configure %{?_smp_mflags}\n# make %{?_smp_mflags}\n\n%install\n\nmake DESTDIR=%{buildroot} install\n\n\n%pre\n# rpm\u6587\u4ef6\u5b89\u88c5\u524d\necho install start....\n\n%post\n# rpm\u6587\u4ef6\u5b89\u88c5\u540e\necho install done\n\n%preun\n# \u5378\u8f7d\u524d\necho uninstall start...\n\n%postun\n# \u5378\u8f7d\u540e\necho uninstall done\n\n%clean\n# \u6e05\u7406\necho clean start...\nmake DESTDIR=%{buildroot} clean\necho clean done...\n\n\n%files\n\n# /path/to/ \u5982\u679c\u662f\u67d0\u4e2a\u76ee\u5f55\u5219\u76f4\u63a5\u628a\u76ee\u5f55\u5199\u5230\u8fd9\u91cc\u5373\u53ef\n/usr/local/Test/bin/test.exe\n\n%doc\n\n# /path/to/docfile \u6587\u6863\u8def\u5f84\n
\n

\n\u6b64\u65f6\u76ee\u5f55\u7ed3\u6784:\n

\n
\n\u251c\u2500\u2500 BUILD\n\u251c\u2500\u2500 BUILDROOT\n\u251c\u2500\u2500 RPMS\n\u251c\u2500\u2500 SOURCES\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 test-1.0.0\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Makefile\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 test.exe\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test-1.0.0.tar.gz\n\u251c\u2500\u2500 SPECS\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test.spec\n\u2514\u2500\u2500 SRPMS\n
\n
\n
\n
\n

1.3. \u6784\u5efaRPM\u6587\u4ef6

\n
\n
\n$ rpmbuild -ba SPECS/test.spec  # \u4e8c\u8fdb\u5236\u548csrc rpm\u6587\u4ef6\n$ rpmbuild -bb SPECS/test.spec  # \u53ea\u751f\u6210\u4e8c\u8fdb\u5236rpm\u6587\u4ef6\n$ rpmbuild -bs SPECS/test.spec  # \u53ea\u751f\u6210src rpm\u6587\u4ef6\n
\n

\n\u76ee\u5f55\u6587\u4ef6:\n

\n
\n\u251c\u2500\u2500 BUILD\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test-1.0.0\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 debugfiles.list\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 debuglinks.list\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 debugsources.list\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 elfbins.list\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 Makefile\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 test.exe\n\u251c\u2500\u2500 BUILDROOT\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test-1.0.0-2.x86_64\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 usr\n\u2502\u00a0\u00a0         \u2514\u2500\u2500 local\n\u2502\u00a0\u00a0             \u2514\u2500\u2500 Test\n\u2502\u00a0\u00a0                 \u2514\u2500\u2500 bin\n\u251c\u2500\u2500 RPMS\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 x86_64\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 test-1.0.0-2.x86_64.rpm\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 test-debuginfo-1.0.0-2.x86_64.rpm\n\u251c\u2500\u2500 SOURCES\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 test-1.0.0\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Makefile\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 test.exe\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test-1.0.0.tar.gz\n\u251c\u2500\u2500 SPECS\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test.spec\n\u2514\u2500\u2500 SRPMS\n
\n
\n
\n
\n

1.4. \u5b89\u88c5\u8f6f\u4ef6\u5305

\n
\n
\n$ sudo rpm -ivh RPMS/x86_64/test-1.0.0-2.x86_64.rpm\n\nPreparing...                          ################################# [100%]\ninstall start....\nUpdating / installing...\n   1:test-1.0.0-2                     ################################# [100%]\ninstall done\n\n$ ls /usr/local/Test/bin/test.exe\n\n/usr/local/Test/bin/test.exe\n
\n
\n
\n
\n

1.5. \u5378\u8f7d\u8f6f\u4ef6\u5305

\n
\n
\n$ sudo rpm -e test-1.0.0-2\nuninstall start...\nuninstall done\n\n$ ll /usr/local/Test/bin/\ntotal 0\n
\n
\n
\n
\n\n
"}, {"title": "\u6807\u51c6\u65e5\u672c\u8bed\u521d\u7ea7(\u7b2c2\u8bfe):\u3053\u308c\u306f\u672c\u3067\u3059", "url": "/2023/01/29/learn_japanese_3.html", "content": "None"}, {"title": "\u6807\u51c6\u65e5\u672c\u8bed\u521d\u7ea7(\u7b2c1\u8bfe):\u674e\u5148\u751f\u662f\u4e2d\u56fd\u4eba", "url": "/2023/01/28/learn_japanese_2.html", "content": "None"}, {"title": "\u5728\u5e0c\u671b\u7684\u7530\u91ce\u4e0a", "url": "/2023/01/23/field_under_the_sun.html", "content": "None"}, {"title": "\u5f17\u6d1b\u4f0a\u5fb7\u4e0e\u300a\u6027\u5b66\u4e09\u8bba\u300b", "url": "/2023/01/15/Freud_Three_Essays_On_The_Theory_Of_Sexuality.html", "content": "None"}, {"title": "LLVM\u6846\u67b6(1):\u5f00\u7bc7", "url": "/2022/12/17/llvm_1.html", "content": "None"}, {"title": "\u5ba2\u5bb6\u4eba\u7684\u4e00\u79cd\u5c11\u89c1\u201c\u4f2f-\u53d4\u201d\u7c7b\u5173\u7cfb\u79f0\u547c", "url": "/2023/01/07/a_special_call_name_of_hakka.html", "content": "None"}, {"title": "\u5173\u4e8e\u5b66\u65e5\u8bed\u8fd9\u4ef6\u4e8b", "url": "/2023/01/06/learn_japanese_1.html", "content": "None"}, {"title": "\u4f7f\u7528Dockerfile\u548cCMake\u7f16\u8bd1LLVM\u7a0b\u5e8f", "url": "/2022/12/28/dockerfile_for_ledge.html", "content": "None"}, {"title": "\u7528readline\u5e93\u6539\u8fdbREPL\u4ea4\u4e92\u4f53\u9a8c", "url": "/2023/01/02/gnu_readline_in_repl.html", "content": "None"}, {"title": "Ledge\u8bed\u8a00\uff1a\u5b57\u8282\u7801\u7f16\u8bd1\u6587\u4ef6\u7684\u5b58\u50a8\u4e0e\u52a0\u8f7d", "url": "/2022/12/27/bytecode_serializer_deserializer.html", "content": "None"}, {"title": "\u7528clang-format\u7edf\u4e00\u4ee3\u7801\u98ce\u683c", "url": "/2022/12/19/git_clang_format.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u7f16\u8bd1\u5668(12):\u7ed3\u8bed", "url": "/2022/12/16/writing_an_interpreter_in_cpp_12.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u7f16\u8bd1\u5668(11):\u95ed\u5305", "url": "/2022/12/16/writing_an_interpreter_in_cpp_11.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u7f16\u8bd1\u5668(10):\u5185\u7f6e\u51fd\u6570", "url": "/2022/12/16/writing_an_interpreter_in_cpp_10.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u7f16\u8bd1\u5668(9):\u51fd\u6570\u4e0e\u6808\u5e27", "url": "/2022/12/13/writing_an_interpreter_in_cpp_9.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u7f16\u8bd1\u5668(8):\u7b26\u53f7\u8868\u3001\u5b57\u7b26\u4e32\u3001\u6570\u7ec4\u4e0e\u5b57\u5178", "url": "/2022/12/12/writing_an_interpreter_in_cpp_8.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u7f16\u8bd1\u5668(7):\u8df3\u8f6c\u6307\u4ee4", "url": "/2022/12/12/writing_an_interpreter_in_cpp_7.html", "content": "None"}, {"title": "\u660e\u5929\u505a\u5ba2\u8981\u65af\u6587", "url": "/2022/12/11/be_a_guest_tomorrow.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u7f16\u8bd1\u5668(6):\u5b57\u8282\u7801\u4e0e\u865a\u62df\u673a", "url": "/2022/11/26/writing_an_interpreter_in_cpp_6.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u89e3\u91ca\u5668(5):\u529f\u80fd\u6269\u5c55", "url": "/2022/11/24/writing_an_interpreter_in_cpp_5.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u89e3\u91ca\u5668(4):\u6c42\u503c", "url": "/2022/11/21/writing_an_interpreter_in_cpp_4.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u89e3\u91ca\u5668(3):\u8bed\u6cd5\u5206\u6790\u4e0e\u666e\u62c9\u7279\u89e3\u6790", "url": "/2022/11/13/writing_an_interpreter_in_cpp_3.html", "content": "None"}, {"title": "Docker\u955c\u50cf\u91cc\u4e3a\u4ec0\u4e48Linux\u65e0\u6cd5\u5b89\u88c5Man Pages\uff1f", "url": "/2022/11/21/man_pages_missing.html", "content": "None"}, {"title": "Linux\u5982\u4f55\u901a\u8fc7PAM\u7ba1\u7406\u6388\u6743?", "url": "/2022/11/21/PAM_in_linux.html", "content": "None"}, {"title": "Linux\u5982\u4f55\u8bbe\u7f6e\u7528\u6237\u957f\u65f6\u95f4\u4e0d\u64cd\u4f5c\u5c31\u81ea\u52a8\u767b\u51fa?", "url": "/2022/11/20/TMOUT_env_variable_in_liunux.html", "content": "None"}, {"title": "Git\u5982\u4f55\u7ba1\u7406\u5b50\u6a21\u5757\u548c\u7b2c\u4e09\u65b9\u6a21\u5757\uff1f", "url": "/2022/11/17/git_subtree_and_submodule.html", "content": "None"}, {"title": "C++\u7591\u96be\u6742\u75c7(1):\u5c0f\u5fc3std::variant\u4e2d\u7684bool\u7c7b\u578b\u503c", "url": "/2022/11/16/cpp_go_to_wrong_1.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u89e3\u91ca\u5668(2):\u8bcd\u6cd5\u5206\u6790", "url": "/2022/11/11/writing_an_interpreter_in_cpp_2.html", "content": "None"}, {"title": "C++\u5b9e\u73b0\u89e3\u91ca\u5668(1):\u5f00\u7bc7", "url": "/2022/11/10/writing_an_interpreter_in_cpp_1.html", "content": "None"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(10):\u5e76\u53d1(\u4e0b)", "url": "/2022/11/04/cpp_10.html", "content": "None"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(9):\u5e76\u53d1(\u4e0a)", "url": "/2022/11/01/cpp_9.html", "content": "None"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(8):\u6a21\u677f", "url": "/2022/11/01/cpp_8.html", "content": "None"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(7):\u51fd\u6570\u5bf9\u8c61(Function Object)", "url": "/2022/10/31/cpp_7.html", "content": "None"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(6): lambda\u8868\u8fbe\u5f0f", "url": "/2022/10/26/cpp_6.html", "content": "
\n

C++\u8bed\u8a00\u5bfc\u5b66(6): lambda\u8868\u8fbe\u5f0f

\n\n
\n

1. \u5f15\u8a00

\n
\n

\nlambda\u8868\u8fbe\u5f0f\u662f\u4e00\u4e2a\u53ef\u6267\u884c\u7684\u4ee3\u7801\u5355\u5143\uff0c\u53ef\u4ee5\u770b\u4f5c\u662f\u4e00\u4e2a\u533f\u540d\u5185\u8054(inline)\u51fd\u6570\uff0c\u4e0b\u9762\u4ee5\u533f\u540d\u51fd\u6570\u4ee3\u6307lambda\u8868\u8fbe\u5f0f\u3002\n

\n

\n\u5b9a\u4e49\u8bed\u6cd5:\n

\n
\n
[capture list] (parameter list) -> return type { function body }\n
\n
\n

\n\u533f\u540d\u51fd\u6570\u7684\u51fd\u6570\u4f53\u4e00\u822c\u64cd\u4f5c\u6bd4\u8f83\u5c11\uff0c\u800c\u4e14\u533f\u540d\u51fd\u6570\u4e00\u822c\u4e0d\u4f1a\u53cd\u590d\u5728\u591a\u5904\u4f7f\u7528\uff0c\u5e38\u662f\u4e00\u6b21\u6027\u7684\u3002\n

\n
\n
\n
\n

2. \u53c2\u6570\u5217\u8868

\n
\n

\n\u6bd4\u5982:\n

\n
\n
auto f = [] { return 42; }\n\nauto f = []() { return 42; } // \u7b49\u6548\n
\n
\n

\n\u8fd9\u4e2a\u51fd\u6570\u6ca1\u6709\u6307\u5b9a\u53c2\u6570\u5c31\u662f\u6ca1\u6709\u53c2\u6570\uff0c\u4e5f\u6ca1\u6709\u6307\u5b9a\u8fd4\u56de\u503c\u7c7b\u578b\uff0c\u5219\u6839\u636e\u6267\u884c\u8bed\u53e5\u5757\u91cc\u9762\u8fd4\u56de\u7684\u7c7b\u578b\u4f5c\u4e3a\u533f\u540d\u51fd\u6570\u7684\u8fd4\u56de\u7c7b\u578b\u3002\n

\n

\n\u6bd4\u5982:\n

\n
\n
auto f = [](const string& a, cosnt string&b) { return a.size() + b.size(); }\n
\n
\n

\nlambda\u8868\u8fbe\u5f0f\u5b9a\u4e49\u7684\u51fd\u6570\u53c2\u6570\u6ca1\u6709\u9ed8\u8ba4\u503c\uff0c\u610f\u5473\u7740\u6bcf\u6b21\u5fc5\u987b\u63d0\u4f9b\u548c\u5b9a\u4e49\u4e00\u6837\u591a\u7684\u5b9e\u53c2\u3002\n

\n
\n
\n
\n

3. \u6355\u83b7\u5217\u8868

\n
\n

\n\u6bd4\u5982:\n

\n
\n
int sz1 = 1024;\nint sz2 = 2048;\n\nauto f = [sz1,sz2](const string& a) { return a.size() >= sz1 && a.size() <= sz2; }\nauto wc = find_if(words.begin(), words.end(), [sz](const string &a) { return a.size() >= sz; });\n
\n
\n

\n\u8fd9\u91cc\u7684sz\u662f\u672c\u5730\u53d8\u91cf\uff0c\u5982\u679c\u8981\u8ba9\u533f\u540d\u51fd\u6570\u53ef\u4ee5\u4f7f\u7528\u672c\u5730\u53d8\u91cf\uff0c\u5219\u9700\u8981\u5728\u4e2d\u62ec\u53f7(\u6355\u83b7\u5217\u8868)\u91cc\u9762\u63d0\u4f9b\u3002\n

\n

\n\u6bd4\u5982:\n

\n
\n
for_each(wc, words.end(), [](const string& s) { cout << s << \" \"; };\n
\n
\n

\n\u533f\u540d\u51fd\u6570\u53ef\u4ee5\u4f7f\u7528cout\uff0c\u867d\u7136cout\u5e76\u6ca1\u6709\u5199\u5230\u6355\u83b7\u5217\u8868\u4e2d\u3002\n

\n

\n\u56e0\u4e3a\u533f\u540d\u51fd\u6570\u5b9a\u4e49\u65f6\u7684\u4e2d\u62ec\u53f7\u6355\u83b7\u5217\u8868\u91cc\u9762\u53ea\u7528\u4e8e\u5199\u672c\u5730\u975e\u9759\u6001\u53d8\u91cf\uff0c\u5982\u679c\u662f\u6240\u5728\u51fd\u6570\u4e4b\u5916\u7684\u5219\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u3002\n

\n

\n\u5c40\u90e8\u53d8\u91cf\u8fdb\u5165\u533f\u540d\u51fd\u6570\u4f7f\u7528\u4f20\u503c\u6216\u5f15\u7528\uff0c\u6bd4\u5982:\n

\n
\n
void fnc1()\n{\n    size_t v1 = 42;    // local variable\n    auto f = [v1] { return v1; }; // copy v1 into f\n\n    v1 = 0;\n    auto j = f(); // j=42, not 0\n}\n\nvoid func2()\n{\n    size v1 = 42; // local variable\n    auto f2 = [&v1] { return v1; };\n\n    v1 = 0;\n    auto j = f2(); // j=0, not 42\n}\n
\n
\n

\n\u5f53\u4f7f\u7528\u5f15\u7528\u4f20\u9012\u65f6\uff0c\u8981\u6ce8\u610f\u5c40\u90e8\u53d8\u91cf\u79bb\u5f00\u4f5c\u7528\u57df\u5c31\u9500\u6bc1\u4e86\uff0c\u56e0\u6b64\u8981\u6ce8\u610f\u533f\u540d\u51fd\u6570\u6267\u884c\u65f6\u6240\u6355\u83b7\u7684\u53d8\u91cf\u662f\u5426\u8fd8\u6709\u6548\u3002\n

\n

\n\u4f20\u9012\u53d8\u91cf\u8fd8\u53ef\u4ee5\u4f7f\u7528\u7b80\u5199\u65b9\u5f0f:\n

\n
\n
auto f = [] { return v1; }; // \u4e0d\u6355\u83b7\nauto f = [=] { return v1; }; // \u81ea\u52a8\u4ee5\u4f20\u503c\u5f62\u5f0f\u6355\u83b7\u53d8\u91cf\nauto f = [&] { return v1; }; // \u81ea\u52a8\u4ee5\u5f15\u7528\u5f62\u5f0f\u6355\u83b7\u53d8\u91cf\n\nauto f = [&,c] { return v1 > c; }; // \u9664\u4e86\u53d8\u91cfc\uff0c\u5176\u4f59\u81ea\u52a8\u5f15\u7528\u4f20\u9012\u6355\u83b7\u53d8\u91cf\nauto f = [=,&c] { return v1 > c; }; // \u9664\u4e86c\uff0c\u5176\u4f59\u81ea\u52a8\u4f20\u503c\u4f20\u9012\u6355\u83b7\u53d8\u91cf\n
\n
\n

\n\u6355\u83b7\u7684\u53d8\u91cf\u662f\u5426\u53ef\u4ee5\u5728\u533f\u540d\u51fd\u6570\u5185\u90e8\u88ab\u6539\u53d8\uff1f\n

\n

\n\u6bd4\u5982:\n

\n
\n
void fcn3()\n{\n    size_t v1 = 42;\n    auto f1 = [v1] { return ++v1; }; // error: \u4f20\u503c\u5f62\u5f0f\u4e0d\u80fd\u6539\u53d8\u6355\u83b7\u53d8\u91cf\u7684\u503c\n    auto f2 = [v1]() mutable { return ++v1; }; // right: \u4f7f\u7528\u4e86mutable\u6807\u8bb0\n    v1 = 0;\n    auto j = f2(); // j = 43\n}\n\nvoid fcn()\n{\n    size_t v1 = 42;\n    const size_t v2 = 42;\n\n    auto f1 = [&v1] { return ++v1; } // right\n    auto f2 = [&v2] { return ++v2; } // error: v2 is const\n\n    v1 = 0;\n    auto j = f1(); // j = 1\n}\n
\n
\n

\n\u4e00\u822c\u662f\u4e0d\u5728\u533f\u540d\u51fd\u6570\u5185\u90e8\u6539\u53d8\u6355\u83b7\u7684\u53d8\u91cf\u7684\u3002\n

\n
\n
\n
\n

4. \u8fd4\u56de\u503c

\n
\n

\n\u5982\u679c\u533f\u540d\u51fd\u6570\u4f53\u53ea\u6709\u4e00\u6761return\u8bed\u53e5\uff0c\u90a3\u4e48\u6700\u7ec8\u533f\u540d\u51fd\u6570\u7684\u8fd4\u56de\u7c7b\u578b\u7531\u8fd9\u4e2areturn\u8bed\u53e5\u51b3\u5b9a:\n

\n
\n
transform(vi.begin(), vi.end(), vi.begin(), \n                                [](int i){ return i < 0 ? -1 : i; });\n
\n
\n

\n\u5982\u679c\u533f\u540d\u51fd\u6570\u4f53\u6709\u591a\u6761return\u8bed\u53e5\uff0c\u90a3\u4e48\u6700\u7ec8\u533f\u540d\u51fd\u6570\u7684\u8fd4\u56de\u5217\u5e2d\u662fvoid:\n

\n
\n
transform(vi.begin(), vi.end(), vi.begin(), \n                                [](int i){ if(i < 0) return -i; else return i; });\n
\n
\n

\n\u5982\u679c\u533f\u540d\u51fd\u6570\u6307\u5b9a\u4e86\u8fd4\u56de\u7c7b\u578b\uff0c\u5219\u4f7f\u7528\u6b64\u8fd4\u56de\u7c7b\u578b:\n

\n
\n
transform(vi.begin(), vi.end(), vi.begin(), \n                                [](int i) -> int \n                                { if(i < 0) return -i; else return i; });\n
\n
\n
\n
\n
"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(5): \u5bb9\u5668", "url": "/2022/10/26/cpp_5.html", "content": "
\n

C++\u8bed\u8a00\u5bfc\u5b66(5): \u5bb9\u5668

\n\n
\n

1. \u5f15\u8a00

\n
\n

\n\u5982\u679c\u4e00\u4e2a\u7c7b\u7684\u4e3b\u8981\u76ee\u7684\u662f\u4fdd\u5b58\u5bf9\u8c61\uff0c\u90a3\u4e48\u901a\u5e38\u79f0\u4e4b\u4e3a\u5bb9\u5668(container)\u3002\n

\n

\n\u8fd9\u91cc\u4e3b\u8981\u7b80\u5355\u6982\u8ff0\u4e00\u4e0b\u8fd9\u4e9b\u6807\u51c6\u5e93\u5bb9\u5668:\n

\n
    \n
  • vector: \u6709\u5e8f\u5e8f\u5217
  • \n
  • list: \u53cc\u5411\u94fe\u8868
  • \n
  • map: \u5173\u8054\u5b57\u5178
  • \n
  • unordered_map: \u65e0\u5e8f\u54c8\u5e0c
  • \n
\n
\n
\n
\n

2. vector

\n
\n

\n\u4e00\u4e2avector\u5c31\u662f\u4e00\u4e2a\u7ed9\u5b9a\u7c7b\u578b\u5143\u7d20\u7684\u5e8f\u5217\uff0c\u5143\u7d20\u5728\u5185\u5b58\u4e2d\u662f\u8fde\u7eed\u5b58\u50a8\u7684\u3002\n

\n

\n\u5bf9\u4e8evector\u6700\u4e3b\u8981\u7684\u64cd\u4f5c\u662fpush_back()\u8ffd\u52a0\u5185\u5bb9\uff0c\u4f46\u5bb9\u91cf\u4e0d\u8db3\u7684\u65f6\u5019\u5b83\u4f1a\u81ea\u52a8\u6269\u5145\u5bb9\u91cf\uff0c\u5b83\u6709\u4e00\u5957\u81ea\u5df1\u7684\u7b56\u7565\u6765\u6269\u5145\u5bb9\u5668\uff0c\u6548\u7387\u5f88\u9ad8\u3002\n

\n

\nvector\u8db3\u591f\u7075\u6d3b\u3001\u9ad8\u6548\uff0c\u5e94\u8be5\u4f5c\u4e3a\u9ed8\u8ba4\u5bb9\u5668\uff1b\u5c3d\u91cf\u907f\u514d\u5bb9\u5668\u7684\u62f7\u8d1d\u590d\u5236\uff0c\u800c\u662f\u4f7f\u7528\u5f15\u7528\u6216\u6307\u9488\u6765\u907f\u514d\u8fd9\u79cd\u8017\u65f6\u64cd\u4f5c\u3002\n

\n

\n\u4f46vector\u4e3a\u4e86\u4fdd\u8bc1\u9ad8\u6548\u4ee5\u5e94\u7528\u5230\u6027\u80fd\u5173\u952e\u7684\u7a0b\u5e8f\u4e2d\uff0c\u4e0d\u4f1a\u8fdb\u884c\u4e0b\u6807\u8d8a\u754c\u68c0\u67e5\uff0c\u6bd4\u5982:\n

\n
\n
#include <iostream>\n#include <vector>\nusing namespace std;\n\nint main(){\n    try{\n        vector<int> vData;\n\n        //int i = vData[vData.size()];\n        int i = vData.at(vData.size()); // \u63a8\u8350\u4f7f\u7528at()\u65b9\u6cd5\u800c\u4e0d\u662f\u4e0b\u6807\u8bbf\u95ee\n\n    } catch(out_of_range& err){\n      cerr << \"range error\\n\";\n    } catch(...){\n      cerr << \"unknow exception\\n\";\n    }\n\n    return 0;\n}\n
\n
\n
\n
\n
\n

3. list

\n
\n

\n\u5982\u679c\u5e0c\u671b\u5728\u4e00\u4e2a\u5e8f\u5217\u4e2d\u6dfb\u52a0\u3001\u5220\u9664\u5143\u7d20\u800c\u4e0d\u9700\u8981\u79fb\u52a8\u5176\u4ed6\u5143\u7d20\uff0c\u5219\u9009\u62e9list\uff0c\u5b83\u662f\u53cc\u5411\u94fe\u8868\u3002\n

\n
\n
#include <iostream>\n#include <list>\n#include <algorithm>\n\nusing namespace std;\n\nvoid display(const list<int>& data){\n    for(auto &x:data)\n        cout << x << \",\";\n    cout << \"\\n\";\n}\n\nint main()\n{\n    list<int> lData{10,2,3,5,8,1};\n    display(lData); // 10,2,3,5,8,1,\n\n    auto p = find(lData.begin(), lData.end(),3);\n    auto q = find(lData.begin(), lData.end(),8);\n\n    lData.insert(p,12); // \u5728\u8fed\u4ee3\u5668p\u524d\u9762\u63d2\u5165\u503c\n    display(lData); // 10,2,12,3,5,8,1,\n\n    lData.erase(p); // \u9500\u6bc1\u5143\u7d20\n    display(lData); // 10,2,12,5,8,1,\n\n    lData.erase(q); // p,q\u5e76\u6ca1\u6709\u56e0\u4e3a\u524d\u9762insert\u64cd\u4f5c\u800c\u5931\u6548\n    display(lData); // 10,2,12,5,1,\n\n    return 0;\n}\n
\n
\n

\n\u5f53\u6570\u636e\u91cf\u8f83\u5c0f\u65f6\uff0cvector\u6027\u80fd\u4f1a\u4f18\u4e8elist\uff0c\u9664\u975e\u6709\u7406\u7531\u9009\u62e9list\uff0c\u5426\u5219\u5e94\u8be5\u4f7f\u7528vector\u3002\n

\n

\nvector\u65e0\u8bba\u5728\u904d\u5386(find,count)\u6027\u80fd\u8fd8\u662f\u6392\u5e8f\u548c\u641c\u7d22(sort,equal_range)\u6027\u80fd\u90fd\u4f18\u4e8elist\u3002\n

\n
\n
\n
\n

4. map

\n
\n

\nmap\u53c8\u53eb\u5173\u8054\u6570\u7ec4\u6216\u5b57\u5178\uff0c\u7528\u5e73\u8861\u4e8c\u53c9\u6811(\u7ea2\u9ed1\u6811)\u5b9e\u73b0\u3002\n

\n
\n
map<string, int> mData{{\"David\",123},{\"Tom\",123}};// David->123;Tom->123;\n\nmData[\"Leslie\"] = 578; // David->123;Leslie->578;Tom->123;\n\nmData[\"Zhu\"]; // David->123;Leslie->578;Tom->123;Zhu->0;\n
\n
\n

\n\u8fdb\u884c\u4e0b\u6807\u64cd\u4f5c\u672c\u8d28\u662f\u8fdb\u884c\u4e00\u6b21\u641c\u7d22\uff0c\u5982\u679c\u6ca1\u627e\u5230key\u5c31\u81ea\u52a8\u63d2\u5165\u65b0\u5143\u7d20\uff0cvalue\u662f\u5bf9\u5e94\u7684\u9ed8\u8ba4\u503c\u3002\n

\n

\n\u4e00\u822c\u5e38\u7528\u64cd\u4f5c\u662ffind()\u548cinsert()\u3002\n

\n
\n
\n
\n

5. unordered_map

\n
\n

\n\u6807\u51c6\u5e93\u4e2d\u54c8\u5e0c\u5bb9\u5668\u88ab\u53eb\u505a\u201c\u65e0\u5e8f\u201d\u5bb9\u5668\u3002\n

\n

\nunderorder_map\u7684\u64cd\u4f5c\u548cmap\u6ca1\u592a\u5927\u533a\u522b\uff0c\u533a\u522b\u5728\u4e8e\u4e0d\u662f\u7528\u4e00\u4e2a\u6709\u5e8f\u51fd\u6570\u8fdb\u884c\u6bd4\u8f83\u64cd\u4f5c\uff0c\u800c\u662f\u4f7f\u7528\u54c8\u5e0c\u51fd\u6570\u3002\n

\n

\n\u6bd4\u5982:\n

\n
\n
#include <iostream>\n#include <unordered_map>\n\nusing namespace std;\n\nstruct Record{\n   friend struct RHash;\n\n   string name;\n   int age;\n\n   Record(const string& s, const int& i): name(s), age(i){}\n\n   bool operator==(const Record& rhs) const {\n       return name == rhs.name && age == rhs.age;\n   }\n};\n\nstruct RHash{\n    size_t operator()(const Record& r) const {\n        return hash<string>()(r.name)^hash<int>()(r.age);\n    }\n};\n\nvoid display(const unordered_map<Record,int,RHash>& data){\n    cout << \"unordered map: \";\n    for(auto &x:data)\n       cout << \"(\"<<x.first.name<<\",\"<<x.first.age<<\")\" << \"->\" << x.second << \";\";\n    cout << \"\\n\";\n}\n\nint main()\n{\n    unordered_map<Record,int,RHash> uData{{{\"David\",26},123}}; // \u4f7f\u7528\u81ea\u5b9a\u4e49\u54c8\u5e0c\u51fd\u6570\n    display(uData); // (David,26)->123;\n\n    uData[Record(\"Tom\",30)] = 456;\n    display(uData); // (Tom,30)->456;(David,26)->123;\n\n    uData[Record(\"Leslie\",35)] = 578;\n    display(uData); // (Leslie,35)->578;(Tom,30)->456;(David,26)->123;\n\n    uData[Record(\"Zhu\",40)];\n    display(uData); // (Zhu,40)->0;(Leslie,35)->578;(Tom,30)->456;(David,26)->123;\n\n    return 0;\n}\n
\n
\n
\n
\n
"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(4): pImpl\u4e60\u60ef\u7528\u6cd5", "url": "/2022/10/26/cpp_4.html", "content": "
\n

C++\u8bed\u8a00\u5bfc\u5b66(4): pImpl\u4e60\u60ef\u7528\u6cd5

\n
\n

\n\u6761\u6b3e31: \u5c06\u6587\u4ef6\u95f4\u7684\u7f16\u8bd1\u4f9d\u5b58\u5173\u7cfb\u964d\u5230\u6700\u4f4e\u3002 \u2014 \u300aEffective C++\u300b\n

\n

\n\u6761\u6b3e22: \u4f7f\u7528pImpl\u4e60\u60ef\u7528\u6cd5\u65f6\uff0c\u5c06\u7279\u6b8a\u6210\u5458\u51fd\u6570\u7684\u5b9a\u4e49\u653e\u5230\u5b9e\u73b0\u6587\u4ef6\u4e2d\u3002 \u2014 \u300aEffective Modern C++\u300b\n

\n
\n

\npImpl\u4e60\u60ef\u7528\u6cd5\uff0c\u5373pointer to implementation\uff0c\u6307\u7684\u662f\u4ee5\u6307\u9488\u7684\u65b9\u5f0f\u8bbf\u95ee\u7c7b\u7684\u5b9e\u73b0\u90e8\u5206\u3002\n

\n

\n\u6bd4\u5982:\n

\n
\n
class Widget {\npublic:\n    Widget();\n    //...\nprivate:\n    std::string name;\n    std::vector<double> data;\n};\n
\n
\n

\n\u5728\u8fd9\u4e2a\u7c7b\u5b9a\u4e49\u4e2d\uff0c\u56e0\u4e3a\u6570\u636e\u6210\u5458\u7684\u7f18\u6545\uff0c\u8fd9\u4e2a\u5934\u6587\u4ef6\u91cc\u9762\u9700\u8981\u5305\u542bstring,vector\u7b49\uff0c\u8fdb\u800c\u5bfc\u81f4\u51e1\u662f\u4f7f\u7528\u4e86\u8fd9\u4e2a\u7c7b\u7684\u5730\u65b9\u90fd\u4f1a\u9700\u8981\u7f16\u8bd1\u4e00\u6b21\u3002\n

\n

\n\u8fd9\u4e0d\u4f46\u63d0\u9ad8\u4e86\u6574\u4f53\u7684\u7f16\u8bd1\u65f6\u95f4\uff0c\u800c\u4e14\u56e0\u4e3a\u4f9d\u8d56\u95ee\u9898\u4e00\u65e6\u6709\u4efb\u4f55\u6539\u53d8\u90fd\u9700\u8981\u91cd\u65b0\u7f16\u8bd1\u4e00\u6b21\u3002\n

\n

\npImpl\u4e60\u60ef\u7528\u6cd5\u53ef\u4ee5\u964d\u4f4e\u4f9d\u8d56\u4ee5\u63d0\u5347\u7f16\u8bd1\u901f\u5ea6\uff0c\u5982:\n

\n
\n
// Widget.hpp\n\nclass Widget{\npublic:\n    Widget();\n    ~Widget();\n    //...\nprivate:\n    struct Impl;  // \u7528\u4e00\u4e2a\u7ed3\u6784\u4f53\u6765\u5b58\u50a8\u5b9e\u73b0\u90e8\u5206\n    Impl *pImpl;  // \u7528\u4e00\u4e2a\u6307\u9488\u6765\u8bbf\u95ee\u5b9e\u73b0\u90e8\u5206\n};\n
\n
\n

\nWidget::Impl\u662f\u4e00\u4e2a\u5185\u90e8\u7684\u975e\u5b8c\u6574\u7c7b\u578b\uff0c\u800c\u8fd9\u91cc\u7684\u6280\u5de7\u5c31\u5728\u4e8e\u7528\u4e00\u4e2a\u6307\u9488\u6765\u6307\u5411\u5b83\uff0c\u4ece\u800c\u4e0d\u9700\u8981\u5305\u542bstring\u7b49\u5934\u6587\u4ef6\uff0c\u4e5f\u4e0d\u4f1a\u56e0\u4e3a\u4f9d\u8d56\u95ee\u9898\u5bfc\u81f4\u8ddf\u968f\u7740\u91cd\u65b0\u7f16\u8bd1\u3002\n

\n

\n\u5728\u5b9e\u73b0\u90e8\u5206\u6765\u5904\u7406\u7c7b\u7684\u6210\u5458:\n

\n
\n
// Widget.cpp\n\nstruct Widget::Impl\n{\n    std::string name;\n    std::vector<double> data;\n};\n\nWidget()\n: pImpl(new Impl)\n{\n}\n\n~Widget()\n{\n    delete pImpl;\n}\n\n// main.cpp\n\n#include \"Widget.hpp\"\n\nint main()\n{\n    Widget w;\n    return 0;\n}\n
\n
\n

\n\u4f46\u6211\u4eec\u60f3\u4f7f\u7528\u667a\u80fd\u6307\u9488\u6765\u5904\u7406\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u4f7f\u7528\u201c\u88f8\u201d\u6307\u9488\uff0c\u4e5f\u4e0d\u60f3\u51fa\u73b0new\u548cdelete\u8bed\u53e5:\n

\n
\n
// Widget.hpp\n\n#include <memory>\n\nclass Widget {\npublic:\n    Widget();\nprivate:\n    struct Impl;\n    std::unique_ptr<Impl> pImpl;\n};\n\n// Widget.cpp\n\n#include \"Widget.hpp\"\n\n#include <string>\n#include <vector>\n\nstruct Widget::Impl\n{\n    std::string name;\n    std::vector<double> data;\n};\n\nWidget::Widget()\n: pImpl(std::make_unique<Impl>())\n{\n}\n
\n
\n

\n\u4f46\u56e0\u4e3a\u4f7f\u7528\u4e86unique_ptr\u667a\u80fd\u6307\u9488\uff0c\u5b83\u4f1a\u56e0\u4e3aImpl\u5728\u5934\u6587\u4ef6\u4e2d\u662f\u4e00\u4e2a\u975e\u5b8c\u6574\u7c7b\u578b\u800c\u62a5\u9519\uff0c\u539f\u56e0\u662f\u7f16\u8bd1\u5668\u81ea\u52a8\u4ea7\u751f\u7684\u4e00\u4e9b\u9ed8\u8ba4\u4ee3\u7801\u65f6\u8fd8\u4e0d\u77e5\u9053Impl\u7684\u5b8c\u6574\u5b9a\u4e49\uff0c\u9700\u8981\u505a\u4e9b\u6539\u52a8:\n

\n
\n
// Widget.hpp\n\n#include <memory>\n\nclass Widget {\npublic:\n    Widget();\n    ~Widget(); // \u4e0d\u4f7f\u7528\u7f16\u8bd1\u5668\u81ea\u52a8\u751f\u6210\u7684\u6790\u6784\u51fd\u6570\nprivate:\n    struct Impl;\n    std::unique_ptr<Impl> pImpl;\n};\n\n// Widget.cpp\n#include \"Widget.hpp\"\n\n#include <string>\n#include <vector>\n\nstruct Widget::Impl\n{\n    std::string name;\n    std::vector<double> data;\n};\n\nWidget::Widget()\n: pImpl(std::make_unique<Impl>())\n{\n}\n\nWidget::~Widget() = default;   // \u8fd8\u662f\u4f7f\u7528\u7f16\u8bd1\u81ea\u52a8\u4ea7\u751f\u7684\u9ed8\u8ba4\u6790\u6784\u51fd\u6570\uff0c\u4f46\u6b64\u65f6\u5df2\u7ecf\u77e5\u9053Impl\u7684\u5b8c\u6574\u5b9a\u4e49\u4e86\u3002\n
\n
\n

\n\u8fd9\u6837\u5c31\u53ef\u4ee5\u987a\u5229\u7f16\u8bd1\u4e86\u3002\n

\n

\n\u4f46\u56e0\u4e3aunique_ptr\u8981\u6c42\u7c7b\u578b\u662f\u5b8c\u6574\u7c7b\u578b\uff0c\u76f8\u5e94\u7684\u9700\u8981\u628a\u4e00\u4e9b\u7279\u6b8a\u51fd\u6570\u8fdb\u884c\u58f0\u660e\u548c\u5b9e\u73b0\uff0c\u8fd9\u6837\u624d\u80fd\u6b63\u786e\u6267\u884c\u79fb\u52a8\u3001\u590d\u5236\u7b49\u64cd\u4f5c:\n

\n
\n
// Widget.hpp\n\n#include <memory>\n\nclass Widget {\npublic:\n    Widget();\n    ~Widget();   // \u6790\u6784\u51fd\u6570\n\n    Widget(Widget&& rhs);  // \u79fb\u52a8\u6784\u9020\u51fd\u6570\n    Widget& operator=(Widget&& rhs); // \u79fb\u52a8\u590d\u5236\u8fd0\u7b97\u7b26\n\n    Widget(const Widget& rhs);   // \u590d\u5236\u6784\u9020\u51fd\u6570 \n    Widget& operator=(const Widget& rhs); // \u590d\u5236\u8d4b\u503c\u8fd0\u7b97\u7b26\n\nprivate:\n    struct Impl;\n    std::unique_ptr<Impl> pImpl;\n};\n\n// Widget.cpp\n\n#include \"Widget.hpp\"\n\n#include <string>\n#include <vector>\n\nstruct Widget::Impl\n{\n    std::string name;\n    std::vector<double> data;\n};\n\nWidget::Widget()\n: pImpl(std::make_unique<Impl>())\n{\n}\n\nWidget::~Widget() = default;\n\nWidget::Widget(Widget&& rhs) = default;\nWidget& Widget::operator=(Widget&& rhs) = default;\n\nWidget::Widget(const Widget& rhs)\n: pImpl(std::make_unique<Impl>(*rhs.pImpl))\n{\n}\n\nWidget& Widget::operator=(const Widget& rhs)\n{\n   *pImpl = *rhs.pImpl;\n   return *this;\n}\n
\n
\n

\n\u6d4b\u8bd5:\n

\n
\n
// main.cpp\n\n#include \"Widget.hpp\"\n\nint main()\n{\n    Widget w;\n\n    Widget w1(w);\n    Widget w2 = w;\n\n    auto w3(std::move(w));\n    auto w4 = std::move(w3);\n\n    return 0;\n}\n
\n
\n

\n\u57fa\u672c\u4e0a\u5728\u91c7\u7528pImpl\u4e60\u60ef\u7528\u6cd5\u65f6\uff0c\u9996\u9009\u4f7f\u7528unique_ptr\u667a\u80fd\u6307\u9488\uff0c\u8fdb\u800c\u5fc5\u987b\u5b9e\u73b0\u7c7b\u7684\u4e94\u4e2a\u7279\u6b8a\u51fd\u6570:\n

\n
    \n
  • \u6790\u6784\u51fd\u6570
  • \n
  • \u79fb\u52a8\u6784\u9020\u51fd\u6570
  • \n
  • \u79fb\u52a8\u8d4b\u503c\u8fd0\u7b97\u7b26
  • \n
  • \u590d\u5236\u6784\u9020\u51fd\u6570
  • \n
  • \u590d\u5236\u8d4b\u503c\u8fd0\u7b97\u7b26
  • \n
\n

\n\u91c7\u7528pImpl\u4e60\u60ef\u7528\u6cd5\u4e0d\u4f46\u52a0\u5feb\u7f16\u8bd1\u901f\u5ea6\uff0c\u800c\u4e14\u505a\u5230\u63a5\u53e3\u548c\u5b9e\u73b0\u7684\u771f\u6b63\u5206\u79bb\uff0c\u5c3d\u53ef\u80fd\u91c7\u7528\u6b64\u7528\u6cd5\u3002\n

\n
"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(3): RAII\u4e0e\u667a\u80fd\u6307\u9488", "url": "/2022/10/25/cpp_3.html", "content": "
\n

C++\u8bed\u8a00\u5bfc\u5b66(3): RAII\u4e0e\u667a\u80fd\u6307\u9488

\n\n
\n

1. \u5f15\u8a00

\n
\n

\nC++\u63d0\u4f9b\u5f00\u53d1\u8005\u81ea\u5b9a\u4e49\u7c7b\u578b\u7684\u80fd\u529b\uff0c\u800c\u5bf9\u4e8e\u81ea\u5b9a\u4e49\u7c7b\u578b\u7684\u8d44\u6e90\u7ba1\u7406\u662f\u4e00\u5927\u96be\u9898\u3002\n

\n

\n\u5bf9\u4e8e\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7c7b\u578b\u6216\u8005class\u6765\u8bf4\uff0c\u53ef\u4ee5\u76f4\u63a5\u521b\u5efa\u5b83\u7684\u5bf9\u8c61\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7new\u4e3a\u5b83\u521b\u5efa\u6307\u9488\u3002\n

\n

\n\u5bf9\u4e8e\u5bf9\u8c61\u548c\u6307\u9488\u7684\u8d44\u6e90\u7ba1\u7406\uff0c\u5206\u522b\u53ef\u4ee5\u4f7f\u7528RAII\u539f\u5219\u548c\u667a\u80fd\u6307\u9488\u6765\u5904\u7406\u3002\n

\n
\n
\n
\n

2. RAII: \u8d44\u6e90\u8bf7\u6c42\u5373\u521d\u59cb\u5316

\n
\n

\n\u5728\u6784\u9020\u51fd\u6570\u4e2d\u8bf7\u6c42\u8d44\u6e90\uff0c\u7136\u540e\u5728\u6790\u6784\u51fd\u6570\u4e2d\u91ca\u653e\u5b83\u4eec\u7684\u6280\u672f\u88ab\u79f0\u4e3a\u8d44\u6e90\u8bf7\u6c42\u5373\u521d\u59cb\u5316(RAII, Resource Acquisition Is Initialization)\u3002\n

\n

\n\u5f53\u6211\u4eec\u521b\u5efa(\u8bf7\u6c42)\u4e00\u4e2a\u5bf9\u8c61\u65f6\uff0c\u901a\u8fc7\u6784\u9020\u51fd\u6570\u5b83\u5df2\u7ecf\u81ea\u52a8\u521d\u59cb\u5316\u597d\u4e86\u8d44\u6e90\uff1b\u5f53\u5bf9\u8c61\u79bb\u5f00\u4f5c\u7528\u57df\u65f6\uff0c\u901a\u8fc7\u6790\u6784\u51fd\u6570\u5b83\u81ea\u52a8\u91ca\u653e\u4e86\u8d44\u6e90\u3002\n

\n

\n\u6574\u4e2a\u8fc7\u7a0b\u4e2d\u5bf9\u8c61\u7684\u8d44\u6e90\u4e0d\u518d\u7531\u8c03\u7528\u8005\u8d1f\u8d23\u7ba1\u7406\uff0c\u800c\u662f\u7531\u5f00\u53d1\u8005\u5728\u5bf9\u8c61\u5185\u90e8\u8bbe\u8ba1\u597d\u3002\n

\n

\n\u5982\u679c\u5bf9\u8c61\u5185\u90e8\u5b9e\u73b0\u6709\u7533\u8bf7\u5185\u5b58\uff0c\u5374\u53c8\u4e0d\u662f\u5728\u6790\u6784\u51fd\u6570\u4e2d\u91ca\u653e\u8d44\u6e90\uff0c\u90a3\u4e48\u5f53\u8fd9\u4e2a\u5bf9\u8c61\u79bb\u5f00\u4f5c\u7528\u57df\u88ab\u9500\u6bc1\u65f6\uff0c\u53ef\u80fd\u4f1a\u56e0\u4e3a\u8d44\u6e90\u6ca1\u6709\u5f97\u5230\u5b8c\u5168\u91ca\u653e\u800c\u9020\u6210\u5185\u5b58\u6cc4\u6f0f\u3002\n

\n

\n\u5e94\u8be5\u5c3d\u91cf\u907f\u514d\u5728\u4e00\u822c\u4ee3\u7801\u4e2d\u76f4\u63a5\u4f7f\u7528new\u548cdelete\uff0c\u800c\u662f\u8981\u9690\u85cf\u5728\u7c7b\u578b\u5185\u90e8\u5b9e\u73b0\uff0c\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u8d44\u6e90\u5f97\u5230\u53ca\u65f6\u7684\u91ca\u653e\u3002\n

\n

\n\u901a\u8fc7RAII\u539f\u5219\u53ef\u4ee5\u786e\u4fdd\u8d44\u6e90\u603b\u662f\u80fd\u591f\u901a\u8fc7\u6790\u6784\u51fd\u6570\u5f97\u5230\u91ca\u653e\u3002\n

\n

\n\u6bd4\u5982:\n

\n
\n
class Vector{\npublic:\n    Vector(int s): elem{new elem[s]}, sz{s}  // \u5206\u914d\u8d44\u6e90\n    {\n        for(int i=0; i != s; i++)  // \u521d\u59cb\u5316\n           elem[i] = 0;\n    }\n\n   ~Vector(){ delete[] elem; }   // \u6790\u6784\u51fd\u6570\u91ca\u653e\u8d44\u6e90\n\n   double& operator[](int i);\n   int size() const;\nprivate:\n   double *elem;\n   int sz;\n};\n
\n
\n

\n\u90a3\u4e48\u5728\u4f7f\u7528\u7684\u65f6\u5019\u5c31\u53ef\u4ee5\u5f53\u5bf9\u8c61\u79bb\u5f00\u4f5c\u7528\u57df\u65f6\u81ea\u52a8\u8c03\u7528\u6790\u6784\u51fd\u6570\u5b8c\u6210\u8d44\u6e90\u7684\u91ca\u653e:\n

\n
\n
void fct(int n)\n{\n    Vector v(n);\n    {\n        Vector v2(2*n);\n    } // v2\u5728\u6b64\u9500\u6bc1\n} // v\u5728\u6b64\u9500\u6bc1\n
\n
\n

\n\u6784\u9020\u51fd\u6570\u4e0e\u6790\u6784\u51fd\u6570\u8fd9\u5957RAII\u673a\u5236\u662f\u5927\u591a\u6570C++\u901a\u7528\u8d44\u6e90\u7ba1\u7406\u6280\u672f\u7684\u57fa\u7840\u3002\n

\n
\n
\n
\n

3. \u667a\u80fd\u6307\u9488

\n
\n

\nnew\u8fd0\u7b97\u7b26\u662f\u4ece\u4e00\u5757\u540d\u4e3a\u81ea\u7531\u5b58\u50a8\u6216\u52a8\u6001\u5185\u5b58(dynamic memory)\u7684\u533a\u57df\u4e2d\u5206\u914d\u5185\u5b58\u3002\n

\n

\n\u5728\u81ea\u7531\u5b58\u50a8\u4e2d\u5206\u914d\u7684\u5bf9\u8c61\u72ec\u7acb\u4e8e\u5b83\u521b\u5efa\u65f6\u6240\u5904\u7684\u4f5c\u7528\u57df\uff0c\u4f1a\u4e00\u76f4\u201c\u5b58\u6d3b\u201d\u5230\u4f7f\u7528delete\u8fd0\u7b97\u7b26\u9500\u6bc1\u5b83\u4e3a\u6b62\u3002\n

\n

\n\u800c\u4f7f\u7528\u201c\u88f8\u201dnew\u548cdelete\u5f88\u5bb9\u6613\u51fa\u5dee\uff0c\u56e0\u4e3a\u4f1a\u51fa\u4e8e\u5404\u79cd\u539f\u56e0\u5fd8\u8bb0\u4f7f\u7528delete\u6216\u8005\u7a0b\u5e8f\u903b\u8f91\u5230\u4e0d\u4e86delete\u8bed\u53e5\u5c31\u5df2\u7ecf\u8fd4\u56de\u4e86\u3002\n

\n

\n\u8fd9\u4e2a\u65f6\u5019\u4e0d\u662fRAII\u539f\u5219\u4e0d\u8d77\u4f5c\u7528\uff0c\u800c\u662f\u6ca1\u6709\u81ea\u52a8\u8c03\u7528\u6790\u6784\u51fd\u6570\u6765\u5b9e\u73b0RAII\u539f\u5219\uff0c\u53ef\u4ee5\u901a\u8fc7\u667a\u80fd\u6307\u9488\u6765\u8ba9\u5b83\u81ea\u52a8\u8c03\u7528\u6790\u6784\u51fd\u6570\u3002\n

\n

\n\u6bd4\u5982:\n

\n
\n
void user(int x)\n{\n    Shape *p = new Circle{Point{0,0}, 10};\n    //...\n    if(x < 0) throw Bad_x{};  // \u5b58\u5728\u6cc4\u6f0f\u5371\u9669\n    if(x < 0) return;         // \u5b58\u5728\u6cc4\u6f0f\u5371\u9669\n    //...\n    delete p;\n}\n
\n
\n

\n\u5728x\u4e0d\u662f\u6b63\u6570\u7684\u65f6\u5019\uff0c\u51fd\u6570\u76f4\u63a5\u8fd4\u56de\u4e86\uff0c\u800c\u6307\u9488p\u5e76\u6ca1\u6709\u6267\u884c\u5230delete\u8bed\u53e5\uff0c\u9020\u6210\u201c\u88f8\u6307\u9488\u201d\u95ee\u9898\u3002\n

\n

\n\u5982\u679c\u8bf4\u6709\u4e00\u79cd\u65b9\u6cd5\uff0c\u5728\u6307\u9488p\u79bb\u5f00\u8fd9\u4e2a\u4f5c\u7528\u57df\u7684\u65f6\u5019\u77e5\u9053\u81ea\u52a8\u9500\u6bc1\u6307\u9488p\u7684\u8bdd\uff0c\u90a3\u4e48\u5c31\u80fd\u591f\u907f\u514d\u8fd9\u4e2a\u95ee\u9898\uff0c\u8fd9\u5c31\u662f\u667a\u80fd\u6307\u9488\uff1a\n

\n
    \n
  • std::unique_ptr\uff1a\u552f\u4e00\u6240\u6709\u6743\uff0c\u7ba1\u7406\u5177\u5907\u4e13\u5c5e\u6240\u6709\u6743\u7684\u8d44\u6e90
  • \n
  • std::shared_ptr\uff1a\u5171\u4eab\u6240\u6709\u6743\uff0c\u7ba1\u7406\u5177\u5907\u5171\u4eab\u6240\u6709\u6743\u7684\u8d44\u6e90
  • \n
  • std::weak_ptr: \u5bf9\u4e8e\u7c7b\u4f3cstd::shared_ptr\u4f46\u6709\u53ef\u80fd\u7a7a\u60ac\u7684\u6307\u9488
  • \n
\n
\n
\n

3.1. std::unique_ptr

\n
\n
\n
class Smiley: public Circle {\n    //...\nprivate:\n    vector<unique_ptr<Shape>> eyes;\n    uniq_ptr<Shape> mouth;\n};\n\nunique_ptr<Shape> read_shape(istream& is)\n{\n    //....\n    return unique_ptr<Shape>{new Circle{p,r}};\n}\n\nvoid user()\n{\n   vector<unique_ptr<Shape>> v;\n   while(cin)\n      v.push_back(read_shape(cin));\n   //...\n}\n
\n
\n

\n\u5f53\u5bf9\u8c61\u88abunique_ptr\u6240\u62e5\u6709\u540e\uff0c\u4f46\u4e0d\u518d\u9700\u8981\u8fd9\u4e2a\u5bf9\u8c61\u65f6\uff0c\u6bd4\u5982\u5bf9\u8c61\u7684unique_ptr\u79bb\u5f00\u4f5c\u7528\u57df\uff0c\u5b83\u4f1a\u81ea\u52a8\u8c03\u7528delete\u91ca\u653e\u5bf9\u8c61\u3002\n

\n

\nstd::unique_ptr\u53ea\u80fd\u79fb\u52a8(std::move)\u4e0d\u80fd\u62f7\u8d1d\uff1a\n

\n
\n
void f1()\n{\n    auto p = make_unique<int>(2);\n    auto q = p;            // \u9519\u8bef\uff0c\u4e0d\u80fd\u62f7\u8d1d\n    auto q = std::move(p); // \u4e4b\u540ep\u7b49\u4e8enullptr,\u540e\u7eedp\u4e0d\u80fd\u518d\u4f7f\u7528\u4e86\n}\n
\n
\n
\n
\n
\n

3.2. std::shared_ptr

\n
\n

\nshared_ptr\u5f88\u591a\u65b9\u9762\u548cunique_ptr\u975e\u5e38\u76f8\u4f3c\uff0c\u552f\u4e00\u7684\u533a\u522b\u662fshared_ptr\u7684\u5bf9\u8c61\u662f\u4f7f\u7528\u62f7\u8d1d\u64cd\u4f5c\uff0c\u800cunique_ptr\u4f7f\u7528\u79fb\u52a8\u8bed\u4e49\u3002\n

\n

\n\u6bd4\u5982:\n

\n
\n
void f(shared_ptr<fstream>);\nvoid g(shared_ptr<fstream>);\n\nvoid user(const string& name, ios_base::openmode mode)\n{\n    shared_ptr<fstream> fp{new fstream(name, mode)};\n\n    if(!*fp) throw No_file{};\n\n    f(fp);\n    g(fp);\n    //...\n}\n
\n
\n

\n\u6bcf\u6b21\u8c03\u7528\u90fd\u62e5\u6709\u8fd9\u4e2a\u5171\u4eab\u667a\u80fd\u6307\u9488\u7684\u4e00\u4efd\u62f7\u8d1d\uff0c\u5f53\u6700\u540e\u4e00\u4e2a\u62f7\u8d1d\u9500\u6bc1\u7684\u65f6\u5019\u5c31\u91ca\u653e\u5bf9\u5e94\u7684\u8d44\u6e90\u4e86\u3002\n

\n
\n
\n
\n

3.3. make_unique, make_shared

\n
\n
\n
auto p1 = make_unique<S>(2,\"Oz\",7.62);\nauto p2 = make_shared<S>(1,\"Ankh Morpork\",4.65);\n
\n
\n

\n\u901a\u8fc7\u6807\u51c6\u5e93memory\u4e2d\u63d0\u4f9b\u7684\u51fd\u6570\u81ea\u52a8\u83b7\u53d6\u5bf9\u5e94\u7684\u667a\u80fd\u6307\u9488\uff0c\u4ece\u800c\u9632\u6b62\u4f7f\u7528\u4e86new\u5374\u53c8\u5fd8\u8bb0\u4ea4\u7ed9\u667a\u80fd\u6307\u9488\u6765\u7ba1\u7406\u3002\n

\n
\n
\n
\n

3.4. \u4f55\u65f6\u4f7f\u7528\u667a\u80fd\u6307\u9488\uff1f

\n
\n
    \n
  • \u5f53\u9700\u8981\u667a\u80fd\u6307\u9488\u65f6\uff0c\u57fa\u672c\u4e0astd::uniq_ptr\u662f\u9996\u9009
  • \n
  • \u5f53\u5171\u4eab\u67d0\u4e2a\u5bf9\u8c61\u65f6\uff0c\u9700\u8981\u6307\u5411\u5171\u4eab\u5bf9\u8c61\u7684\u6307\u9488\u6216\u5f15\u7528\uff0c\u9009\u62e9shared_ptr
  • \n
  • \u5f53\u5f15\u7528\u4e00\u4e2a\u591a\u6001\u5bf9\u8c61\u65f6\uff0c\u5f88\u96be\u77e5\u9053\u5bf9\u8c61\u5230\u5e95\u662f\u4ec0\u4e48\u7c7b\u578b\uff0c\u5219\u9700\u8981\u4e00\u4e2a\u6307\u9488\uff0c\u6b64\u65f6unique_ptr\u662f\u5fc5\u7136\u9009\u62e9
  • \n
  • \u5171\u4eab\u7684\u591a\u6001\u5bf9\u8c61\u901a\u5e38\u9700\u8981shared_ptr
  • \n
  • \u4f18\u5148\u4f7f\u7528make_unique\u548cmake_shared\uff0c\u800c\u4e0d\u662f\u81ea\u5df1\u6765new
  • \n
\n
\n
\n
\n
\n

4. \u603b\u7ed3

\n
\n
    \n
  • \u5bf9\u4e8e\u81ea\u5b9a\u4e49\u7c7b\u578b\uff0c\u4f7f\u7528RAII\u539f\u5219\u7ba1\u7406\u8d44\u6e90\u7684\u7533\u8bf7\u4e0e\u91ca\u653e\uff0c\u5185\u90e8\u5b9e\u73b0\u4e2d\u6784\u9020\u51fd\u6570\u548c\u6790\u6784\u51fd\u6570\u5206\u522b\u4f7f\u7528new\u548cdelete
  • \n
  • \u5f53\u9700\u8981\u4f7f\u7528\u6307\u9488\u65f6\uff0c\u4f18\u5148\u4f7f\u7528\u667a\u80fd\u6307\u9488\uff0c\u5e76\u4e14\u4f7f\u7528make_unique\u548cmake_shared\u521b\u5efa\u667a\u80fd\u6307\u9488\uff0c\u4e00\u822c\u4ee3\u7801\u91cc\u9762\u4e0d\u9700\u8981\u51fa\u73b0new\u548cdelete
  • \n
\n
\n
\n
"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(2): \u6a21\u5757\u5316", "url": "/2022/10/23/cpp_2.html", "content": "
\n

C++\u8bed\u8a00\u5bfc\u5b66(2): \u6a21\u5757\u5316

\n\n
\n

1. \u5f15\u8a00

\n
\n

\n\u7a0b\u5e8f\u7ec4\u7ec7\u7684\u6700\u4f73\u65b9\u5f0f\u662f\u5c06\u7a0b\u5e8f\u770b\u4f5c\u4f9d\u8d56\u5173\u7cfb\u5b9a\u4e49\u826f\u597d\u7684\u4e00\u7ec4\u6a21\u5757\uff0c\u5728\u903b\u8f91\u4e0a\u901a\u8fc7\u8bed\u8a00\u7279\u6027\u8868\u8fbe\u6a21\u5757\u5316\uff0c\u5728\u7269\u7406\u4e0a\u901a\u8fc7\u6587\u4ef6\u6a21\u5757\u5316\u5b9e\u73b0\u9ad8\u6548\u7684\u5206\u522b\u7f16\u8bd1\u3002\n

\n

\n\u7a0b\u5e8f\u6e90\u7801\u6587\u4ef6\u6a21\u5757\u5316\u6700\u91cd\u8981\u7684\u4e00\u6b65\u662f\u5c06\u6bcf\u4e2a\u7ec4\u6210\u90e8\u5206\u7684\u63a5\u53e3\u548c\u5b9e\u73b0\u5206\u79bb\u5f00\u6765\uff0c\u501f\u52a9\u5206\u522b\u7f16\u8bd1\u3001\u540e\u7eed\u94fe\u63a5\u7684\u65b9\u5f0f\u63d0\u9ad8\u7f16\u8bd1\u6548\u7387\u3002\n

\n

\n\u4ee5\u5f80\u662f\u901a\u8fc7\u5934\u6587\u4ef6(*.hpp)\u548c\u5b9e\u73b0\u6587\u4ef6(*.cpp)\u6765\u8fbe\u5230\u5206\u79bb\u76ee\u7684\uff0c\u5728\u7f16\u8bd1\u4e3a\u52a8\u6001\u94fe\u63a5\u5e93(*.so)\u4f9b\u5176\u4ed6\u4eba\u4f7f\u7528\u7684\u65f6\u5019\u7279\u522b\u65b9\u4fbf\uff0c\u53ef\u4ee5\u8fbe\u5230\u9690\u85cf\u7ec6\u8282\u7684\u76ee\u7684\u3002\n

\n

\n\u4f46\u4f7f\u7528 #include \u662f\u4e00\u79cd\u53e4\u8001\u3001\u6613\u51fa\u9519\u4e14\u4ee3\u4ef7\u4e0d\u5c0f\u7684\u7a0b\u5e8f\u6a21\u5757\u5316\u7ec4\u7ec7\u65b9\u5f0f\uff0c\u4eceC++20\u5f00\u59cb\u5f15\u5165 module \u7279\u6027\uff0cGCC11\u652f\u6301\u6b64\u529f\u80fd:\n

\n
\n

\n$ g++ -std=c++20 -fmodules-ts file.cpp\n

\n
\n

\n\u4f7f\u7528\u6a21\u5757\u529f\u80fd\u53ef\u4ee5\u63d0\u9ad8\u7f16\u8bd1\u6548\u7387\u548c\u53ef\u7ef4\u62a4\u6027:\n

\n
    \n
  • \u4e00\u4e2a\u6a21\u5757\u53ea\u4f1a\u7f16\u8bd1\u4e00\u6b21\uff0c\u800cinclude\u53ea\u8981\u5305\u542b\u4e00\u6b21\u5c31\u4f1a\u7f16\u8bd1\u4e00\u6b21
  • \n
  • \u4e24\u4e2a\u6a21\u5757\u53ef\u4ee5\u6309\u4efb\u610f\u987a\u5e8f\u5bfc\u5165\u800c\u4e0d\u4f1a\u6539\u53d8\u5b83\u4eec\u7684\u542b\u4e49
  • \n
  • import\u6ca1\u6709\u4f20\u9012\u6027
  • \n
\n

\n\u4f46\u76ee\u524d\u6765\u770b\uff0c\u4f7f\u7528module\u529f\u80fd\u4e0d\u662f\u90a3\u4e48\u5bb9\u6613\uff0c\u5c24\u5176\u662f\u65e7\u4ee3\u7801\u8fc1\u79fb\u3001\u65b0\u65e7\u4ee3\u7801\u5e76\u5b58\u7f16\u8bd1\u4f1a\u662f\u4e00\u4e2a\u4e0d\u5c0f\u7684\u6311\u6218\u3002\n

\n

\n\u53e6\u5916\uff0c\u4ee3\u7801\u7684\u9759\u6001\u5e93\u3001\u4e8c\u8fdb\u5236\u7b49\u5206\u53d1\u4f1a\u6bd4\u8f83\u56f0\u96be\uff0c\u7ec6\u5fae\u7684ABI\u5dee\u5f02\u90fd\u5bfc\u81f4\u65e0\u6cd5\u5171\u4eab\u4f7f\u7528\u3002\n

\n
\n
\n
\n

2. module\u4f8b\u5b50: \u5934\u6587\u4ef6\u53d8\u6210\u6a21\u5757

\n
\n

\nhello.hpp:\n

\n
\n
constexpr int num=3;\n
\n
\n

\nrun.cpp:\n

\n
\n
import \"hello.hpp\";\n
\n
\n

\n\u9700\u8981\u5148\u5c06\u8fd9\u4e2a\u5355\u72ec\u7684\u5934\u6587\u4ef6\u7f16\u8bd1\u4e3a\u6a21\u5757\u540e\u624d\u80fdimport\u4f7f\u7528:\n

\n
\n$ g++ -c -std=c++20 -fmodule-header hello.hpp  # \u751f\u6210gcm.cache/,/hello.hpp.gcm\n$ g++ -c -std=c++20 -fmodules-ts run.cpp       # \u751f\u6210run.o\n
\n
\n
\n
\n

3. module\u4f8b\u5b50: \u6a21\u5757\u63a5\u53e3\u548c\u5b9e\u73b0\u5728\u4e00\u8d77

\n
\n

\nVector.cpp\n

\n
\n
module;\n\nexport module Vector;\n\nexport class Vector{\npublic:\n    Vector(int s);\n    double& operator[](int i);\n    int size() const;\nprivate:\n    double *elem;\n    int sz;\n};\n\nVector::Vector(int s)\n    :elem{new double[s]}, sz{s}\n    {\n    }\n\ndouble& Vector::operator[](int i){\n    return elem[i];\n}\n\nint Vector::size() const{\n    return sz;\n}\n\nexport int size(const Vector& v){ return v.size(); }\n
\n
\n

\nmain.cpp:\n

\n
\n
import Vector;\n\n#include <iostream>\n#include <cmath>\n\ndouble sqrt_sum(Vector& v)\n{\n    double sum = 0;\n    for(int i=0; i != v.size(); i++)\n    {\n        sum += std::sqrt(v[i]);\n    }\n\n    return sum;\n}\n\nint main()\n{\n    Vector v(5);\n    v[0] = 1;\n    v[1] = 2;\n    v[2] = 3;\n    v[3] = 4;\n\n    double sum = sqrt_sum(v);\n    std::cout << \"size: \" << size(v) << \", sum: \" << sum << std::endl;\n    return 0;\n}\n
\n
\n

\n\u7f16\u8bd1\u4e0e\u6267\u884c:\n

\n
\n$ g++ -c -std=c++20  -fmodules-ts Vector.cpp  # \u521b\u5efaVector.o\u548cgcm.cache/Vector.gcm\n$ g++ -c -std=c++20  -fmodules-ts main.cpp    # \u521b\u5efamain.o\n$ g++ main.o Vector.o -o main                 # \u521b\u5efamain\n\nor\n\n$ g++ -std=c++20 -fmodules-ts Vector.cpp main.cpp -o main\n\n$ ./main\nsize: 5, sum: 6.14626\n
\n

\n\u67e5\u770b\u6a21\u5757\u6587\u4ef6\u4fe1\u606f(.gcm):\n

\n
\n$ readelf -p.gnu.c++.README gcm.cache/Vector.gcm\n\nString dump of section '.gnu.c++.README':\n  [     0]  GNU C++ primary module interface\n  [    21]  compiler: 11.2.1 20210728 (Red Hat 11.2.1-1)\n  [    4e]  version: 2021/07/28-09:09\n  [    68]  module: Vector\n  [    77]  source: Vector.cpp\n  [    8a]  dialect: C++20/coroutines\n  [    df]  repository: gcm.cache\n
\n
\n
\n
\n

4. module\u4f8b\u5b50: \u6a21\u5757\u63a5\u53e3\u4e0e\u5b9e\u73b0\u5206\u79bb

\n
\n

\nVector.cpp:\n

\n
\n
module;\n\nexport module Vector;\n\nexport class Vector{\npublic:\n    Vector(int s);\n    double& operator[](int i);\n    int size() const;\nprivate:\n    double *elem;\n    int sz;\n};\n\n\nexport int size(const Vector& v);\n
\n
\n

\nVector_impl.cpp:\n

\n
\n
module;\n\nmodule Vector;\n\n\nVector::Vector(int s)\n    :elem{new double[s]}, sz{s}\n    {\n    }\n\ndouble& Vector::operator[](int i){\n    return elem[i];\n}\n\nint Vector::size() const{\n    return sz;\n}\n\nint size(const Vector& v){ return v.size(); }\n
\n
\n

\nmain.cpp:\n

\n
\n
#include <iostream>\n#include <cmath>\n\nimport Vector;\n\ndouble sqrt_sum(Vector& v)\n{\n    double sum = 0;\n    for(int i=0; i != v.size(); i++)\n    {\n        sum += std::sqrt(v[i]);\n    }\n\n    return sum;\n}\n\nint main()\n{\n    Vector v(5);\n    v[0] = 1;\n    v[1] = 2;\n    v[2] = 3;\n    v[3] = 4;\n\n    double sum = sqrt_sum(v);\n    std::cout << \"size: \" << size(v) << \", sum: \" << sum << std::endl;\n    return 0;\n}\n
\n
\n

\n\u7f16\u8bd1\u4e0e\u6267\u884c:\n

\n
\n$ g++ -c -std=c++20 -fmodules-ts Vector.cpp      # \u751f\u6210Vector.o\u548cgcm.cache/Vector.gcm\n$ g++ -c -std=c++20 -fmodules-ts Vector_impl.cpp # \u751f\u6210Vector_impl.o\n$ g++ -c -std=c++20 -fmodules-ts main.cpp        # \u751f\u6210main.o\n$ g++ -std=c++20 -fmodules-ts main.o Vector_impl.o Vector.o -o main\n\nor\n\n$ g++ -std=c++20 -fmodules-ts Vector.cpp Vector_impl.cpp main.cpp -o main\n
\n

\n\u6ce8\u610f, Vector.cpp\u5982\u679c\u6587\u4ef6\u540d\u6539\u6210Vector.hpp\u5219\u4f1a\u8ba4\u4e3a\u662f\u666e\u901a\u5934\u6587\u4ef6\uff0c\u800c\u4e0d\u662f\u6a21\u5757\u7684\u63a5\u53e3\u6587\u4ef6(cmi)\uff0c\u9700\u52a0\u4e0a -x c++ \u9009\u9879: \n

\n
\n$ g++ -c -std=c++20 -fmodules-ts Vector.hpp   # \u4f1a\u76f4\u63a5\u5f53\u505a\u666e\u901a\u7684\u5934\u6587\u4ef6\u5904\u7406\u800c\u62a5\u9519\nVector.hpp:1:1: error: module-declaration not permitted in header-unit\n\n$ g++ -c -std=c++20 -fmodules-ts -x c++ Vector.hpp  # \u8ba9\u7f16\u8bd1\u5668\u81ea\u5df1\u5224\u65ad\u51fa\u662fmodule\u63a5\u53e3\u6587\u4ef6(cmi)\n$ g++ -c -std=c++20 -fmodules-ts -x c++ Vector.hpp Vector_impl.cpp\n$ g++ -std=c++20 -fmodules-ts -x c++ Vector.hpp Vector_impl.cpp main.cpp -o main\n
\n
\n
\n
\n

5. module\u4f8b\u5b50\uff1a\u5b50\u6a21\u5757

\n
\n
    \n
  • \u5b50\u6a21\u5757: TestMod.Vector
  • \n
\n

\nVector.hpp:\n

\n
\n
module;\n\nexport module TestMod.Vector;  // \u8fd9\u91cc\u5176\u5b9e\u662f\u4e00\u4e2a\u5b8c\u6574\u7684\u6a21\u5757\u540d\u5b57\uff0c\u8fd9\u4e2a'.'\u6ca1\u6709\u4efb\u4f55\u4ece\u5c5e\u610f\u4e49\n\nexport class Vector{\npublic:\n    Vector(int s);\n    double& operator[](int i);\n    int size() const;\nprivate:\n    double *elem;\n    int sz;\n};\n\n\nexport int size(const Vector& v);\n
\n
\n

\nVector.cpp:\n

\n
\n
module;\n\nmodule TestMod.Vector;\n\n\nVector::Vector(int s)\n    :elem{new double[s]}, sz{s}\n    {\n    }\n\ndouble& Vector::operator[](int i){\n    return elem[i];\n}\n\nint Vector::size() const{\n    return sz;\n}\n\nint size(const Vector& v){ return v.size(); }\n
\n
\n
    \n
  • \u5b50\u6a21\u5757: TestMod.funcs
  • \n
\n

\nfuncs.hpp:\n

\n
\n
export module TestMod.funcs;\n\nexport void func1();\nexport void func2();\n
\n
\n

\nfuncs.cpp:\n

\n
\n
module;\n\n#include <iostream>\n\nmodule TestMod.funcs;\n\nvoid func1(){\n    std::cout << \"func1\" << std::endl;\n}\n\nvoid func2(){\n    std::cout << \"func2\" << std::endl;\n}\n
\n
\n
    \n
  • \u6a21\u5757: TestMod
  • \n
\n

\nTestMod.hpp:\n

\n
\n
export module TestMod;\nexport import TestMod.Vector;\nexport import TestMod.funcs;\n
\n
\n
    \n
  • main.cpp
  • \n
\n
\n
#include <iostream>\n#include <cmath>\n\nimport TestMod;\n\ndouble sqrt_sum(Vector& v)\n{\n    double sum = 0;\n    for(int i=0; i != v.size(); i++)\n    {\n        sum += std::sqrt(v[i]);\n    }\n\n    return sum;\n}\n\nint main()\n{\n    Vector v(5);\n    v[0] = 1;\n    v[1] = 2;\n    v[2] = 3;\n    v[3] = 4;\n\n    double sum = sqrt_sum(v);\n    std::cout << \"size: \" << size(v) << \", sum: \" << sum << std::endl;\n\n    func1();\n    func2();\n\n    return 0;\n}\n
\n
\n

\n\u7f16\u8bd1:\n

\n
\n$ g++ -c -std=c++20 -fmodules-ts -x c++ Vector.hpp Vector.cpp\n$ g++ -c -std=c++20 -fmodules-ts -x c++ funcs.hpp funcs.cpp\n$ g++ -c -std=c++20 -fmodules-ts -x c++ TestMod.hpp\n\n$ g++ -c -std=c++20 -fmodules-ts -x c++ Vector.hpp Vector.cpp funcs.hpp funcs.cpp TestMod.hpp\n\n$ g++ -std=c++20 -fmodules-ts -x c++ Vector.hpp Vector.cpp funcs.hpp funcs.cpp TestMod.hpp main.cpp -o main\n\n$ ./main\nsize: 5, sum: 6.14626\nfunc1\nfunc2\n
\n
\n
\n
\n

6. \u8d44\u6599

\n\n
\n
"}, {"title": "C++\u8bed\u8a00\u5bfc\u5b66(1): \u57fa\u7840\u77e5\u8bc6", "url": "/2022/10/22/cpp_1.html", "content": "
\n

C++\u8bed\u8a00\u5bfc\u5b66(1): \u57fa\u7840\u77e5\u8bc6

\n\n
\n

1. \u524d\u8a00

\n
\n
\n

\n\u8981\u60f3\u5199\u51fa\u597d\u7684C++\u7a0b\u5e8f\uff0c\u4e0d\u5fc5\u4e86\u89e3C++\u7684\u6240\u6709\u7ec6\u8282\u3002\n

\n
\n

\n\u4ee5C++17\u6807\u51c6\u4e3a\u6700\u65b0\u5b9a\u4e49\uff0c\u5feb\u901f\u4e86\u89e3\u73b0\u4ee3C++\u8bed\u8a00:\n

\n
\n$ g++ -std=c++17 file.cpp\n
\n
\n
\n
\n

2. auto\u4e0e\u5217\u8868\u521d\u59cb\u5316

\n
\n

\n\u53d8\u91cf\u4f18\u5148\u4f7f\u7528\u901a\u7528\u7684\u5217\u8868\u521d\u59cb\u5316\u5f62\u5f0f {} \uff0c\u4ee5\u907f\u514d\u5728\u7c7b\u578b\u8f6c\u6362\u4e2d\u4e22\u5931\u4fe1\u606f:\n

\n
\n
int i1 = 7.8; // i1\u53d8\u6210\u4e867\uff0c\u9690\u5f0f\u6536\u7f29\u8f6c\u6362\nint i2 {7.8};  // \u9519\u8bef: \u6d6e\u70b9\u6570\u5411\u6574\u6570\u8f6c\u6362\nint i2 = {7.8};  // \u9519\u8bef: \u6d6e\u70b9\u6570\u5411\u6574\u6570\u8f6c\u6362\n
\n
\n

\n\u53d8\u91cf\u7c7b\u578b\u5728\u6ca1\u6709\u7279\u6b8a\u7406\u7531\u9700\u8981\u663e\u5f0f\u6307\u5b9a\u6570\u636e\u7c7b\u578b\u65f6\uff0c\u4e00\u822c\u4f7f\u7528 auto :\n

\n
\n
auto b = true;    // bool\nauto ch = 'x';    // char\nauto i = 123;     // int\nauto d = 1.2;     // double\nauto z = sqrt(y); // sqrt\u7684\u8fd4\u56de\u7c7b\u578b\nauto bb {true};   // bool\n
\n
\n

\n\u7279\u6b8a\u7406\u7531\u5305\u62ec:\n

\n
    \n
  • \u4f4d\u4e8e\u4e00\u4e2a\u8f83\u5927\u7684\u4f5c\u7528\u57df\u4e2d\uff0c\u5e0c\u671b\u63d0\u9ad8\u4ee3\u7801\u7684\u6613\u8bfb\u6027\uff0c\u660e\u786e\u6570\u636e\u7c7b\u578b
  • \n
  • \u9700\u8981\u660e\u786e\u4e00\u4e2a\u53d8\u91cf\u7684\u8303\u56f4\u548c\u7cbe\u5ea6\uff0c\u6bd4\u5982\u5e0c\u671b\u4f7f\u7528double\u800c\u4e0d\u662ffloat
  • \n
\n
\n
\n
\n

3. \u7a7a\u6307\u9488: nullptr

\n
\n

\n\u4e0d\u518d\u4f7f\u7528 0 \u6216 NULL \u8868\u793a\u7a7a\u6307\u9488\uff0c\u4f7f\u7528 nullptr \uff0c\u6240\u6709\u6307\u9488\u7c7b\u578b\u90fd\u5171\u4eab\u540c\u4e00\u4e2a nullptr.\n

\n

\n\u68c0\u9a8c\u53d8\u91cf\u662f\u5426\u4e3a 0 \u6216 nullptr \u5c3d\u91cf\u91c7\u7528\u7b80\u6d01\u5f62\u5f0f:\n

\n
\n
while(*p) // \u7b49\u540c: while(*p != 0)\n{\n  //...\n}\n\nif(p)  // \u7b49\u540c: if(p != nullptr)\n{\n  //...\n}\n\nvoid do_something(const vector<int>& v)\n{\n    if(auto n = v.size())\n    {\n        // n != 0\n    }\n}\n
\n
\n
\n
\n
\n

4. \u5c3d\u91cf\u4e0d\u76f4\u63a5\u4f7f\u7528union

\n
\n

\n\u6bd4\u5982\u6709\u8fd9\u6837\u4e00\u4e2a\u8054\u5408\u7684\u5b9a\u4e49:\n

\n
\n
enum Type {ptr, num };\n\nunion Value {\n    Node *p;\n    int i;\n};\n\nstruct Entry {\n    Type t;\n    Value v;\n};\n\nvoid f(Entry* pe) {\n    if(pe->t == num) {\n        cout << pe->v.i;\n    }\n}\n
\n
\n

\n\u5c3d\u91cf\u5c11\u4f7f\u7528\u8fd9\u79cd\u539f\u59cbunion\u5f62\u5f0f\uff0c\u6539\u4e3a\u4f7f\u7528\u6807\u51c6\u5e93\u7c7b\u578bvariant\uff0c\u5e76\u4e14\u5e94\u8be5\u5c01\u88c5\u5230\u4e00\u4e2a\u7c7b\u5185\u90e8\u4ece\u800c\u53ea\u4e3a\u5b83\u670d\u52a1:\n

\n
\n
#include <variant>\n\nstruct Entry {\n    Type t;\n    std::variant<Node *, int> v;\n};\n\nvoid f(Entry* pe) {\n    if(std::holds_alternative<int>(pe->v)){\n        std::cout << std::get<int>(pe->v);\n    }\n}\n
\n
\n
\n
\n
\n

5. \u679a\u4e3e\u4f18\u5148\u4f7f\u7528enum class

\n
\n

\n\u4ee5\u5f80\u7684enum\u4e2d\u679a\u4e3e\u503c\u4f5c\u7528\u57df\u4e0eenum\u4f5c\u7528\u57df\u4e00\u81f4\uff0c\u9690\u5f0f\u8f6c\u6362\u4e3aint\u7c7b\u578b\u503c:\n

\n
\n
enum Color {red, green, blue};  // \u4ece0\u5f00\u59cb\nenum Clolor2 {red2=1, green2, blue2};  // \u4ece1\u5f00\u59cb\n\nint col = green; // 1\nint col2 = green2; // 2\n
\n
\n

\n\u4f7f\u7528\u5e26\u5f3a\u7c7b\u578b\u7684\u679a\u4e3e\u5219\u4e0d\u4f1a\u51fa\u73b0\u540d\u5b57\u51b2\u7a81\uff0c\u800c\u4e14\u907f\u514d\u4e86\u9690\u5f0f\u8f6c\u6362:\n

\n
\n
enum class Color;  // \u53ef\u4ee5\u524d\u7f6e\u58f0\u660e\n\nenum class Color { red, green, blue};\nenum class Color2 { red=1, green, blue};\n\nColor col = Color::green;\nColor2 col2 = Color2::green;\n\nint col_i = static_cast<int>(Color::green); // 1, \u9700\u8981\u663e\u5f0f\u8f6c\u6362\u4e3aint\nint col2_i = static_cast<int>(Color2::green); // 2\n
\n
\n
\n
\n
"}, {"title": "\u5988\uff0c\u6211\u60f3\u8981\u4e00\u672c\u5b57\u5178\uff01", "url": "/2020/05/10/I_want_a_dictionary.html", "content": "
\n

\u5988\uff0c\u6211\u60f3\u8981\u4e00\u672c\u5b57\u5178\uff01

\n

\n\u8fd9\u5929\u662f\u5468\u65e5\uff0c\u4e5f\u6b63\u597d\u662f\u6bcd\u4eb2\u8282\uff0c\u4f46\u5ab3\u5987\u5374\u9700\u8981\u4e0a\u73ed\uff0c\u65e0\u6cd5\u966a\u5b69\u5b50\u4e00\u8d77\u8fc7\u8282\u3002\n

\n

\n\u5b69\u5b50\u4e94\u516d\u5c81\u4e86\uff0c\u65e9\u4e0a\u548c\u5b69\u5b50\u4e00\u8d77\u6d17\u6f31\u7684\u65f6\u5019\uff0c\u5b69\u5b50\u95ee\uff1a\u201c\u5988\u5988\u5462\uff1f\u201d\n

\n

\n\u6211\u5f88\u9ad8\u5174\u5b69\u5b50\u4f1a\u4e3b\u52a8\u95ee\u8d77\u5988\u5988\uff0c\u4e5f\u660e\u767d\u5b83\u4e3a\u4ec0\u4e48\u4f1a\u8fd9\u6837\u95ee\uff0c\u56e0\u4e3a\u4e00\u822c\u5468\u672b\u7684\u65e9\u4e0a\u662f\u5988\u5988\u966a\u4ed6\u6d17\u6f31\u7684\u3002\n

\n

\n\u6211\u5e26\u70b9\u53f9\u606f\u8bf4\u9053\uff1a\u201c\u5988\u5988\u53bb\u4e0a\u73ed\u4e86\u554a\u3002\u3002\u3002\u201d\n

\n

\n\u5b69\u5b50\u671b\u7740\u6211\uff0c\u8ffd\u95ee\u9053\uff1a\u201c\u4e3a\u4ec0\u4e48\u8981\u4e0a\u73ed\u5462\uff1f\u4eca\u5929\u4e0d\u662f\u6bcd\u4eb2\u8282\u5417\uff1f\u201d\n

\n

\n\u6211\u4e00\u65f6\u4e0d\u77e5\u5982\u4f55\u56de\u7b54\u3002\n

\n

\n\u6628\u5929\u665a\u4e0a\u5ab3\u5987\u4e0b\u73ed\u56de\u6765\u540e\uff0c\u5df2\u7ecf\u4e3a\u5bb6\u91cc\u505a\u4e86\u4e00\u4e2a\u86cb\u7cd5\uff0c\u5c31\u5f53\u662f\u966a\u5b69\u5b50\u8fc7\u6bcd\u4eb2\u8282\u4e86\u3002\n

\n

\n\u6211\u8bf4\uff1a\u201c\u4eca\u5929\u662f\u6bcd\u4eb2\u8282\u554a\uff0c\u4f46\u5988\u5988\u9700\u8981\u53bb\u4e0a\u73ed\u7684\uff1b\u4e0d\u8fc7\u5988\u5988\u4e3a\u4f60\u505a\u597d\u4e86\u86cb\u7cd5\uff0c\u5988\u5988\u662f\u4e0d\u662f\u5f88\u7231\u4f60\u554a\uff1f\u201d\n

\n

\n\u5b69\u5b50\u9ad8\u9ad8\u5174\u5174\u7684\u6d17\u6f31\u4e86\u3002\n

\n

\n\u8fd9\u6bb5\u65f6\u95f4\u56e0\u4e3a\u75ab\u60c5\uff0c\u5e7c\u513f\u56ed\u8fdf\u8fdf\u4e0d\u80fd\u5f00\u5b66\uff0c\u4e00\u76f4\u53ea\u80fd\u5446\u5728\u5bb6\u91cc\u8fc7\u65e0\u6bd4\u6f2b\u957f\u7684\u5bd2\u5047\u3002\n

\n

\n\u5b69\u5b50\u662f\u5f00\u5fc3\u7684\uff0c\u53ef\u4ee5\u6bcf\u5929\u770b\u7535\u89c6\u548c\u75af\u73a9\uff0c\u4f46\u5bb6\u957f\u662f\u5d29\u6e83\u7684\uff0c\u6bd4\u5982\u6211\uff0c\u65e2\u8981\u5728\u5bb6\u91cc\u8fdc\u7a0b\u529e\u516c\uff0c\u8fd8\u8981\u6253\u7406\u5b69\u5b50\u7684\u751f\u6d3b\u8d77\u5c45\u3002\n

\n

\n\u5982\u679c\u5b69\u5b50\u6bd4\u8f83\u542c\u8bdd\u597d\u7ba1\u4e5f\u5c31\u7f62\u4e86\uff0c\u504f\u504f\u81ea\u5df1\u5b69\u5b50\u662f\u4e2a\u4e0d\u670d\u7ba1\u6559\u7684\u8c03\u76ae\u5b69\u5b50\uff0c\u4e00\u5929\u5230\u665a\u60f3\u7740\u770b\u7535\u89c6\uff0c\u4e0d\u7231\u5b66\u4e60\u3002\n

\n

\n\u4f46\u597d\u5728\u5bb6\u91cc\u5c31\u6211\u4e00\u4e2a\u5927\u4eba\uff0c\u53ef\u4ee5\u4e00\u8a00\u5802\uff0c\u4e5f\u53ef\u4ee5\u4e07\u4e8b\u5546\u91cf\u7740\u6765\uff0c\u76ee\u7684\u5c31\u662f\u5728\u81ea\u5df1\u5f97\u7a7a\u7684\u65f6\u5019\uff0c\u6293\u7d27\u4e00\u70b9\u5b69\u5b50\u7684\u5b66\u4e60\u3002\n

\n

\n\u76ee\u524d\u9636\u6bb5\u4e3b\u8981\u662f\u7b80\u5355\u7684\u6570\u5b66\u52a0\u51cf\u6cd5\u548c\u6c49\u5b57\u62fc\u97f3\uff0c\u5176\u5b83\u7684\u4e5f\u5b9e\u5728\u6ca1\u6709\u7cbe\u529b\u548c\u80fd\u529b\u6765\u6559\u4e86\u3002\n

\n

\n\u7167\u4f8b\uff0c\u5403\u5b8c\u5348\u996d\u6211\u51fa\u4e86\u4e00\u5f20\u5c0f\u8bd5\u5377\uff0c\u5305\u542b\u5199\u6570\u5b57\u548c\u52a0\u51cf\u6cd5\uff0c\u5b69\u5b50\u5f88\u4e0d\u60c5\u613f\u7684\u5728\u63a8\u8131\u4e0d\u4e86\u7684\u60c5\u51b5\u4e0b\uff0c\u4e56\u4e56\u5b8c\u6210\u4e86\u3002\n

\n

\n\u770b\u7740\u5199\u7684\u4e03\u626d\u516b\u62d0\u7684\u6570\u5b57\uff0c\u53ea\u80fd\u53f9\u4e00\u53e3\u6c14\uff0c\u8ba9\u4ed6\u81ea\u5df1\u5199\u4e0a\u65e5\u671f\u3001\u59d3\u540d\uff0c\u7136\u540e\u81ea\u5df1\u7ed9\u81ea\u5df1\u6253\u5206\uff0c\u7167\u4f8b\u90fd\u8981\u6253\u4e0a100\u5206\uff0c\u5426\u5219\u5c31\u8981\u54ed\u9f3b\u5b50\u3002\n

\n

\n\u8fd9\u6837\uff0c\u4e00\u5929\u7684\u5b66\u4e60\u5c31\u7b97\u5b8c\u4e86\uff0c\u4f46\u6211\u7684\u6298\u78e8\u624d\u521a\u521a\u5f00\u59cb\u3002\n

\n

\n\u4e09\u56db\u5c81\u7684\u65f6\u5019\u7ed9\u4ed6\u4e70\u4e86\u4e00\u5957\u5927\u82f1\u767e\u79d1\u5168\u4e66\uff0c\u4ed6\u5929\u5929\u7ffb\uff0c\u5404\u79cd\u95ee\uff0c\u83ab\u540d\u5176\u5999\u7684\u5c31\u559c\u6b22\u4e86\u5404\u79cd\u86c7\u3002\n

\n

\n\u4e00\u5929\u5230\u665a\u627e\u673a\u4f1a\u8ba9\u6211\u7ed9\u4ed6\u67e5\u5404\u79cd\u86c7\u7684\u56fe\u7247\u548c\u89c6\u9891\u770b\uff0c\u6bd4\u5982\u53f6\u9f3b\u86c7\u3001\u7b04\u86ed\u3002\n

\n

\n\u5728\u6211\u67e5\u7684\u65f6\u5019\uff0c\u4ed6\u8fd8\u4e00\u526f\u6559\u4e66\u5148\u751f\u7684\u6837\u8bf4\uff1a\u201c\u7b04\u662f\u7af9\u5b57\u5934\u7684\uff0c\u86ed\u662f\u6c34\u86ed\u7684\u86ed\uff0c\u77e5\u9053\u4e86\u6ca1\u6709\uff1f\u201d\n

\n

\n\u628a\u6211\u6c14\u5f97\u8bf4\u4e0d\u51fa\u8bdd\u6765\uff0c\u540e\u6765\u6211\u5c31\u62ff\u4e00\u5f20\u7eb8\uff0c\u5199\u4e0a\u201c\u7b04\u86ed\u201d\u4e24\u4e2a\u5b57\uff0c\u7136\u540e\u5199\u4e0a\u62fc\u97f3\uff1b\u7136\u540e\u544a\u8bc9\u4ed6\uff0c\u4f60\u81ea\u5df1\u53bb\u7535\u8111\u4e0a\u67e5\u3002\n

\n

\n\u4ed6\u5c31\u754f\u754f\u7f29\u7f29\u3001\u53cd\u590d\u786e\u8ba4\u62fc\u97f3\u6ca1\u6253\u9519\u540e\uff0c\u67e5\u5230\u4e00\u4e2a\u201c\u7b04\u86ed\u201d\u5f00\u5fc3\u7684\u4e0d\u5f97\u4e86\u3002\n

\n

\n\u6211\u4e5f\u4e3a\u81ea\u5df1\u7684\u673a\u667a\u6697\u6697\u81ea\u559c\uff0c\u4f46\u540e\u9762\u7684\u70e6\u607c\u968f\u4e4b\u800c\u6765\u3002\n

\n

\n\u6709\u4e00\u6b21\u4ed6\u770b\u4e00\u4e2a\u7ba1\u6c34\u6bcd\u7684\u89c6\u9891\uff0c\u4e0a\u9762\u6709\u4e00\u4e2a\u82f1\u6587\u5355\u8bcd\uff0c\u95ee\u6211\u662f\u4ec0\u4e48\u610f\u601d\u3002\n

\n

\n\u6211\u5fc3\u60f3\u5b69\u5b50\u8fd9\u4e48\u597d\u5b66\uff0c\u8981\u597d\u597d\u5f15\u5bfc\uff0c\u5c31\u7528\u624b\u673a\u6253\u5f00\u8c37\u6b4c\u7ffb\u8bd1\u7684\u7167\u76f8\u7ffb\u8bd1\u529f\u80fd\uff0c\u5bf9\u7167\u89c6\u9891\u4e0a\u7684\u82f1\u6587\u5c31\u81ea\u52a8\u770b\u5230\u7ffb\u8bd1\u4e86\u3002\n

\n

\n\u4f46\u540e\u9762\u4e8b\u6001\u8d85\u51fa\u4e86\u6211\u7684\u9884\u4f30\uff0c\u4ed6\u53c8\u770b\u5230\u5f88\u591a\u89c6\u9891\u91cc\u9762\u7684\u82f1\u6587\u5355\u8bcd\uff0c\u975e\u8981\u6211\u544a\u8bc9\u662f\u4ec0\u4e48\u610f\u601d\uff0c\u4f46\u7ffb\u8bd1\u4e5f\u7ffb\u8bd1\u4e0d\u51fa\u6765\uff0c\u56e0\u4e3a\u662f\u975e\u5e38\u4e13\u4e1a\u7684\u751f\u7269\u672f\u8bed\u5355\u8bcd\u3002\n

\n

\n\u8fd9\u6837\u7684\u4e8b\u60c5\u6bcf\u5929\u5728\u4e0a\u6f14\uff0c\u5b69\u5b50\u6bcf\u5929\u8ba9\u6211\u67e5\u4e1c\u67e5\u897f\uff0c\u4f46\u4ed6\u81ea\u5df1\u7684\u62fc\u97f3\u80fd\u529b\u5374\u5e76\u6ca1\u6709\u4ec0\u4e48\u63d0\u9ad8\uff0c\u6211\u60f3\u662f\u65b9\u6cd5\u4e0d\u5bf9\u3002\n

\n

\n\u4e8e\u662f\uff0c\u6211\u8ddf\u4ed6\u8bf4\uff1a\u201c\u6211\u7ed9\u4f60\u4e70\u4e00\u672c\u5b57\u5178\u597d\u4e0d\u597d\uff0c\u4f60\u60f3\u67e5\u4ec0\u4e48\u4f60\u5c31\u53bb\u4e0a\u9762\u770b\uff0c\u770b\u5230\u62fc\u97f3\u540e\u81ea\u5df1\u5c31\u53ef\u4ee5\u5728\u7535\u8111\u4e0a\u67e5\u4e86\u3002\u201d\n

\n

\n\u4ed6\u6b23\u7136\u7b54\u5e94\u3002\n

\n

\n\u5f88\u5feb\uff0c\u4ed6\u5f97\u5230\u4e86\u4e00\u672c\u5b57\u5178\u3002\n

\n

\n\u770b\u7740\u8fd9\u672c\u5b57\u5178\uff0c\u6211\u60f3\u5230\u4e86\u81ea\u5df1\u7684\u6bcd\u4eb2\uff0c\u5979\u4e5f\u66fe\u7ed9\u6211\u4e70\u8fc7\u4e00\u672c\u5b57\u5178\u3002\n

\n

\n\u90a3\u662f2001\u5e74\uff0c\u4ece\u5c0f\u5b66\u5347\u521d\u4e2d, \u90a3\u5929\u6b63\u597d\u662f\u62a5\u540d\u5f00\u5b66\u7684\u65e5\u5b50\u3002\n

\n

\n\u4ece\u5b66\u6821\u62a5\u5230\u5b8c\u540e\uff0c\u56de\u5bb6\u65f6\u8def\u8fc7\u96c6\u5e02\uff0c\u672c\u60f3\u8bf4\u7ed9\u6211\u4e70\u4ef6\u8863\u670d\u5f00\u5b66\u7a7f\uff0c\u4f46\u770b\u6765\u770b\u53bb\u90fd\u4e0d\u559c\u6b22\u3002\n

\n

\n\u8def\u8fc7\u96c6\u5e02\u8fb9\u4e0a\u7684\u4e2d\u5fc3\u5c0f\u5b66\uff0c\u5c0f\u5b66\u95e8\u53e3\u6709\u4e2a\u8001\u5927\u7237\u6446\u644a\u5356\u4e00\u4e9b\u5b66\u4e60\u8d44\u6599\u548c\u4e66\u7c4d\uff0c\u6211\u770b\u4e2d\u4e86\u4e00\u672c\u65b0\u534e\u5b57\u5178\u3002\n

\n

\n\u7ffb\u4e86\u7ffb\uff0c\u5bf9\u6bcd\u4eb2\u8bf4\uff1a\u201c\u5988\uff0c\u6211\u60f3\u8981\u4e00\u672c\u5b57\u5178\uff01\u201d\n

\n

\n\u6bcd\u4eb2\u770b\u51fa\u4e86\u6211\u60f3\u4e70\u7684\u610f\u601d\uff0c\u95ee\uff1a\u201c\u4f60\u4eec\u4e0a\u5b66\u9700\u8981\u5b57\u5178\u5417\uff1f\u201d\n

\n

\n\u6211\u600f\u600f\u7684\u8bf4\uff1a\u201c\u6709\u5b57\u5178\u5f53\u7136\u597d\uff0c\u53ef\u4ee5\u67e5\u4e00\u4e9b\u4e0d\u8ba4\u8bc6\u7684\u5b57\uff0c\u4f46\u5927\u90e8\u5206\u5b57\u6211\u90fd\u8ba4\u8bc6\u4e86\u3002\u201d\n

\n

\n\u6bcd\u4eb2\u95ee\u4e86\u4ef7\u94b1\uff0c\u662f\u4e94\u5757\u94b1\u4e00\u672c\uff0c\u72b9\u8c6b\u4e86\u4e00\u4e0b\u8fd8\u662f\u4e70\u4e86\u3002\n

\n

\n\u90a3\u672c\u5b57\u5178\u966a\u7740\u6211\u5ea6\u8fc7\u4e86\u521d\u4e2d\u65f6\u671f\u3002\n

\n

\n\u90a3\u65f6\u5019\u4e66\u672c\u4e0a\u5df2\u7ecf\u6709\u4e86\u6587\u8a00\u6587\uff0c\u81ea\u5df1\u4e5f\u770b\u4e86\u5f88\u591a\u5c0f\u8bf4\uff0c\u867d\u7136\u8fd9\u672c\u5b57\u5178\u5e76\u6ca1\u6709\u53d1\u6325\u592a\u5927\u7684\u4f5c\u7528\uff0c\u4f46\u6bcd\u4eb2\u5bf9\u6211\u5b66\u4e60\u7684\u652f\u6301\u5374\u8bb0\u5728\u5fc3\u5934\u3002\n

\n

\n\u65f6\u8fc7\u5883\u8fc1\uff0c\u7269\u662f\u4eba\u975e\uff0c\u90a3\u5df2\u7ecf\u662f\u4e8c\u5341\u5e74\u524d\u7684\u4e8b\u60c5\u4e86\u3002\n

\n

\n\u771f\u6000\u5ff5\u90a3\u4e9b\u53ef\u4ee5\u8131\u53e3\u800c\u51fa\u53eb\u4e00\u58f0\u201c\u5988\u201d\u7684\u5c81\u6708\uff01\n

\n
"}, {"title": "\u79ef\u96e8\u4e91", "url": "/2019/10/17/\u79ef\u96e8\u4e91.html", "content": "
\n

\u79ef\u96e8\u4e91

\n

\n\u65e9\u4e0a\u51fa\u95e8\u7684\u65f6\u5019\uff0c\u5b69\u5b50\u8bf4\u5929\u4e0a\u6709\u6735\u79ef\u96e8\u4e91\uff0c\u9648\u6d01\u6d01\u53ea\u662f\u7b11\u4e00\u7b11\u3002\n

\n

\n\u4f46\u4ece\u5e7c\u513f\u56ed\u95e8\u53e3\u51fa\u6765\u65f6\uff0c\u773c\u770b\u5929\u8272\u6108\u53d1\u4f4e\u6c89\uff0c\u6015\u662f\u4e00\u4f1a\u513f\u771f\u6709\u96e8\uff0c\u5fc3\u91cc\u4e0d\u514d\u6709\u70b9\u62c5\u5fc3\u3002\n

\n

\n\u5b8b\u5f3a\u5750\u5728\u8f66\u91cc\u5e76\u672a\u7184\u706b\uff0c\u9648\u6d01\u6d01\u628a\u5b69\u5b50\u9001\u8fdb\u5e7c\u513f\u56ed\u540e\uff0c\u50cf\u5f80\u5e38\u4e00\u6837\u5750\u4e0a\u8f66\u628a\u63a5\u9001\u5361\u88c5\u5230\u5305\u91cc\u3002\n

\n

\n\u300c\u54ce\uff0c\u4e0d\u662f\u8fd9\u8fb9\uff0c\u6211\u4eca\u5929\u4e0d\u4e0a\u73ed\u554a\uff01\u300d\uff0c\u5b8b\u5f3a\u542f\u52a8\u8f66\u5b50\u521a\u8981\u5f80\u5357\u8d70\uff0c\u9648\u6d01\u6d01\u7b11\u7740\u53eb\u4e86\u8d77\u6765\u3002\n

\n

\n\u5b8b\u5f3a\u53ea\u597d\u62d0\u5f2f\u5411\u5317\uff0c\u53ef\u4e0d\u662f\u561b\uff0c\u6bcf\u5929\u9001\u5b8c\u5b69\u5b50\u4e0a\u5b66\u63a5\u7740\u9001\u5ab3\u5987\u4e0a\u73ed\uff0c\u90fd\u6210\u6761\u4ef6\u53cd\u5c04\u4e86\u3002\n

\n

\n\u4eca\u5929\u9648\u6d01\u6d01\u4e0d\u53bb\u4e0a\u73ed\uff0c\u800c\u662f\u53bb\u4e00\u5bb6\u65b0\u516c\u53f8\u9762\u8bd5\uff0c\u76ee\u524d\u8fd9\u4e2a\u5de5\u4f5c\u5b9e\u5728\u662f\u5e72\u4e0d\u4e0b\u53bb\u4e86\uff0c\u62db\u7684\u65b0\u4eba\u5de5\u8d44\u6bd4\u8001\u5458\u5de5\u9ad8\uff0c\u800c\u8001\u5458\u5de5\u5de5\u8d44\u5374\u6b7b\u6d3b\u4e0d\u6da8\u3002\n

\n

\n\u4e0d\u8fc7\u51e0\u5206\u949f\u5230\u4e86\u5730\u94c1\u53e3\uff0c\u548c\u5b8b\u5f3a\u544a\u522b\u540e\u5750\u4e0a\u4e09\u53f7\u7ebf\u5730\u94c1\u3002\n

\n

\n\u9648\u6d01\u6d01\u60f3\u8d77\u8fd9\u4e00\u5e74\u6765\u7684\u5de5\u4f5c\uff0c\u5bb6\u91cc\u53d1\u751f\u4e86\u5f88\u5927\u7684\u53d8\u5316\uff0c\u592b\u59bb\u5f7c\u6b64\u90fd\u627f\u53d7\u7740\u5f88\u5927\u7684\u538b\u529b\u3002\n

\n

\n\u53c8\u60f3\u8d77\u56e0\u4e3a\u8fd9\u4efd\u5de5\u4f5c\u8001\u662f\u52a0\u73ed\uff0c\u5b8b\u5f3a\u5e38\u5e26\u7740\u5b69\u5b50\u5728\u516c\u53f8\u697c\u5e95\u4e0b\u7b49\u81ea\u5df1\u4e0b\u73ed\uff0c\u800c\u81ea\u5df1\u5374\u8fdf\u8fdf\u65e0\u6cd5\u4e0b\u697c\uff0c\u60f3\u5230\u4ed6\u4eec\u7236\u5b50\u4fe9\u5931\u671b\u800c\u53bb\uff0c\u5fc3\u91cc\u6709\u51e0\u5206\u6127\u759a\u3002\n

\n

\n\u5730\u94c1\u64ad\u62a5\u4e0b\u4e00\u7ad9\u5c31\u662f\u5c0f\u5be8\u4e86\uff0c\u9648\u6d01\u6d01\u5927\u5b66\u5c31\u662f\u5728\u5c0f\u5be8\u9644\u8fd1\u8bfb\u7684\uff0c\u90a3\u91cc\u53d1\u751f\u7684\u6bcf\u4e00\u4ef6\u4e8b\u90fd\u6df1\u6df1\u7684\u5370\u5728\u5979\u7684\u5fc3\u91cc\u3002\n

\n

\n\u9762\u8bd5\u7ecf\u7406\u662f\u4e2a\u4e09\u5341\u6765\u5c81\u7684\u4e2d\u5e74\u4eba\uff0c\u4e00\u8eab\u636f\u996c\u7684\u633a\u6709\u6d3e\u5934\uff0c\u628a\u5979\u7b80\u5386\u53cd\u590d\u7684\u770b\u3002\n

\n

\n\u300c\u54b1\u4eec\u4ee5\u524d\u8ba4\u8bc6\uff0c\u6211\u53eb\u5f20\u660e\u7a0b\uff0c\u8fd8\u8bb0\u5f97\u5417\uff1f\u300d\n

\n

\n\u770b\u9648\u6d01\u6d01\u4e00\u8138\u832b\u7136\uff0c\u5f20\u660e\u7a0b\u5e2e\u7740\u56de\u5fc6\uff1a\u300c\u597d\u51e0\u5e74\u524d\u5427\uff0c\u90a3\u4f1a\u4f60\u521a\u6bd5\u4e1a\uff0c\u53bb\u53c2\u52a0\u4e00\u4e2a\u62db\u8058\u4f1a\u8ba4\u8bc6\u7684\u3002\u300d\n

\n

\n\u9648\u6d01\u6d01\u52aa\u529b\u7684\u60f3\uff0c\u4f46\u8fd8\u662f\u60f3\u4e0d\u8d77\u6765\uff0c\u4f46\u542c\u5230\u5f20\u660e\u7a0b\u8bf4\uff1a\u300c\u90a3\u6b21\uff0c\u6211\u4e0d\u4f46\u8bf7\u4f60\u5403\u996d\uff0c\u6700\u540e\u8fd8\u5f00\u8f66\u9001\u4f60\u53bb\u4f60\u7537\u670b\u53cb\u5b66\u6821\u4e86\uff01\u300d\uff0c\u5979\u5dee\u70b9\u5c16\u53eb\u7ad9\u8d77\u6765\u3002\n

\n

\n\u5979\u7684\u601d\u7eea\u8fc5\u901f\u56de\u5fc6\uff0c\u7684\u786e\u6709\u8fd9\u4e48\u4e00\u56de\u4e8b\u3002\n

\n

\n\u90a3\u65f6\u5927\u5b66\u521a\u6bd5\u4e1a\uff0c\u53bb\u53c2\u52a0\u4e00\u4e2a\u62db\u8058\u4f1a\uff0c\u7136\u540e\u5f20\u660e\u7a0b\u4ee3\u8868\u516c\u53f8\u6765\u62db\u4eba\u3002\n

\n

\n\u672c\u6765\u662f\u8bf4\u8bf4\u8bf4\u7b11\u7b11\uff0c\u540e\u6765\u5230\u4e86\u5348\u996d\u65f6\u95f4\uff0c\u5c31\u4e00\u8d77\u5403\u4e86\u987f\u996d\uff1b\u5403\u996d\u671f\u95f4\uff0c\u95ee\u8d77\u5979\u6709\u6ca1\u6709\u7537\u670b\u53cb\u3002\n

\n

\n\u9648\u6d01\u6d01\u90a3\u65f6\u6b63\u662f\u60c5\u7aa6\u521d\u5f00\u70ed\u604b\u671f\uff0c\u5c31\u5f88\u5f00\u5fc3\u7684\u5206\u4eab\u4e86\u81ea\u5df1\u7684\u5e78\u798f\u7231\u60c5\u751f\u6d3b\u3002\n

\n

\n\u53ef\u80fd\u662f\u5979\u592a\u9ad8\u5174\u4e86\uff0c\u8bf4\u7684\u592a\u5feb\uff0c\u8bf4\u7684\u592a\u591a\uff0c\u8bf4\u7684\u592a\u6295\u5165\uff0c\u8ba9\u5f20\u660e\u7a0b\u89c9\u5f97\u81ea\u5df1\u5e94\u8be5\u544a\u8beb\u4e00\u4e0b\u773c\u524d\u8fd9\u4f4d\u5929\u771f\u7684\u50bb\u59d1\u5a18\u3002\n

\n

\n\u5f20\u660e\u7a0b\u7b49\u5979\u5e73\u9759\u4e0b\u6765\uff0c\u8bf4\uff1a\u300c\u4f60\u73b0\u5728\u8fd8\u592a\u5e74\u8f7b\uff0c\u8fd8\u628a\u7231\u60c5\u770b\u7684\u592a\u91cd\uff0c\u6211\u544a\u8bc9\u4f60\uff0c\u7231\u60c5\u9760\u4e0d\u4f4f\uff01\u300d\n

\n

\n\u300c\u4f60\u4e5f\u6ca1\u6bd4\u6211\u5927\u51e0\u5c81\u554a\uff0c\u600e\u4e48\u7231\u60c5\u5c31\u9760\u4e0d\u4f4f\uff0c\u6211\u76f8\u4fe1\u6211\u7537\u670b\u53cb\u3002\u300d\uff0c\u9648\u6d01\u6d01\u89c9\u5f97\u5bf9\u65b9\u8bf4\u8fd9\u6837\u7684\u8bdd\u5f88\u6ca1\u6709\u793c\u8c8c\u3002\n

\n

\n\u5f20\u660e\u7a0b\u7b11\u7740\u8bf4\uff1a\u300c\u6709\u53e5\u8bdd\u600e\u4e48\u8bf4\u6765\u7740\uff0c\u6bd5\u4e1a\u5c31\u5206\u624b\uff01\u300d\n

\n

\n\u770b\u9648\u6d01\u6d01\u6ca1\u6709\u8bf4\u8bdd\uff0c\u4ed6\u63a5\u7740\u53d1\u51fa\u81ea\u5df1\u7684\u5fe0\u544a\uff1a\u300c\u8fd9\u7537\u4eba\u554a\uff0c\u51fa\u4e86\u793e\u4f1a\u4ee5\u540e\u8bf1\u60d1\u592a\u591a\u4e86\uff0c\u8c01\u8fd8\u770b\u91cd\u7231\u60c5\u554a\u3002\u300d\n

\n

\n\u9648\u6d01\u6d01\u65e0\u529b\u7684\u53cd\u9a73\u5230\uff1a\u300c\u53cd\u6b63\u6211\u76f8\u4fe1\u6211\u7537\u670b\u53cb\u3002\u300d\n

\n

\n\u300c\u5728\u751f\u610f\u573a\u4e0a\u6df7\uff0c\u8fd9\u6837\u7684\u6211\u89c1\u591a\u4e86\uff0c\u4fe1\u4e0d\u4fe1\u6211\u53eb\u6211\u516c\u53f8\u7684\u5973\u516c\u5173\uff0c\u4e00\u5929\u628a\u4f60\u7537\u670b\u53cb\u62ff\u4e0b\uff0c\u6562\u4e0d\u6562\u8bd5\u8bd5\uff1f\u300d\n

\n

\n\u9648\u6d01\u6d01\u89c9\u5f97\u81ea\u5df1\u8be5\u8d70\u4e86\uff0c\u771f\u4e0d\u5e94\u8be5\u5403\u8fd9\u987f\u996d\uff0c\u542c\u8fd9\u4e9b\u6df7\u8d26\u8bdd\u3002\n

\n

\n\u51fa\u4e86\u996d\u5e97\uff0c\u5916\u9762\u5374\u5df2\u7ecf\u662f\u6fdb\u6fdb\u7ec6\u96e8\uff0c\u5f20\u660e\u7a0b\u8ddf\u51fa\u6765\u8bf4\uff0c\u5e72\u8106\u4ed6\u5f00\u8f66\u9001\u4e00\u6bb5\u3002\n

\n

\n\u5f53\u77e5\u9053\u9648\u6d01\u6d01\u662f\u8981\u53bb\u7537\u670b\u53cb\u5b66\u6821\u65f6\uff0c\u5f20\u660e\u7a0b\u89c9\u5f97\u8fd9\u8d9f\u975e\u9001\u4e0d\u53ef\u4e86\u3002\n

\n

\n\u4e00\u8def\u4e0a\u5f20\u660e\u7a0b\u770b\u9648\u6d01\u6d01\u6709\u70b9\u751f\u6c14\uff0c\u5fd9\u9053\u6b49\u7684\u8bf4\uff1a\n

\n

\n\u300c\u5176\u5b9e\u6211\u521a\u624d\u8bf4\u90a3\u756a\u8bdd\u6ca1\u6709\u6076\u610f\uff0c\u6211\u4e00\u770b\u4f60\u5c31\u50cf\u81ea\u5df1\u7684\u8868\u59b9\u4e00\u6837\uff0c\u662f\u6015\u4f60\u5728\u611f\u60c5\u4e16\u754c\u91cc\u9677\u5f97\u592a\u6df1\u53d7\u4f24\u5bb3\u3002\u300d\n

\n

\n\u5927\u5b66\u57ce\u8fd9\u8fb9\u5012\u6ca1\u6709\u4e0b\u96e8\uff0c\u8f66\u5b50\u505c\u5230\u5b8b\u5f3a\u5b66\u6821\u95e8\u53e3\uff0c\u9648\u6d01\u6d01\u5fc3\u60c5\u597d\u4e86\u4e0d\u5c11\uff0c\u60f3\u7740\u4e0d\u7ba1\u600e\u6837\uff0c\u4eba\u5bb6\u9001\u4e86\u81ea\u5df1\u4e00\u8d9f\uff0c\u8fd8\u662f\u7b11\u7740\u611f\u8c22\u4e86\u5f20\u660e\u7a0b\u3002\n

\n

\n\u8fd9\u6b21\u9648\u6d01\u6d01\u6765\u627e\u5b8b\u5f3a\u4e5f\u662f\u4e34\u65f6\u8d77\u610f\uff0c\u53ef\u80fd\u662f\u5f20\u660e\u7a0b\u8bf4\u7684\u90a3\u756a\u8bdd\u8ba9\u5979\u5fc3\u91cc\u5835\u7684\u614c\uff0c\u53ea\u6709\u548c\u5b8b\u5f3a\u89c1\u4e00\u9762\u597d\u597d\u804a\u804a\uff0c\u5979\u624d\u80fd\u5fc3\u5b89\u3002\n

\n

\n\u5b8b\u5f3a\u6765\u5230\u5b66\u6821\u56fe\u4e66\u9986\u5916\uff0c\u89c1\u9648\u6d01\u6d01\u4f2b\u7acb\u5728\u82b1\u575b\u8fb9\u62db\u624b\uff0c\u5e76\u672a\u8868\u73b0\u7684\u6709\u591a\u4e48\u559c\u60a6\uff0c\u4ed6\u6b63\u4e3a\u81ea\u5df1\u88ab\u6253\u6270\u800c\u4e0d\u5feb\u3002\n

\n

\n\u4ed6\u662f\u5982\u6b64\u51b7\u51b0\u51b0\uff0c\u9648\u6d01\u6d01\u53ea\u597d\u5f00\u53e3\u8bf4\uff1a\u300c\u4f60\u731c\u731c\u4eca\u5929\u6211\u600e\u4e48\u8fc7\u6765\u7684\uff1f\u300d\n

\n

\n\u300c\u6211\u731c\u4e0d\u7740\uff0c\u5750\u516c\u4ea4\u8f66\u5457\uff0c\u8fd8\u80fd\u600e\u4e48\u8fc7\u6765\u300d\n

\n

\n\u300c\u4e0d\u662f\uff0c\u4f60\u80af\u5b9a\u731c\u4e0d\u51fa\u6765\uff0c\u662f\u522b\u4eba\u5f00\u8f66\u9001\u6211\u8fc7\u6765\u7684\u3002\u300d\uff0c\u770b\u7740\u5b8b\u5f3a\u72d0\u7591\u7684\u773c\u795e\uff0c\u9648\u6d01\u6d01\u4e00\u8138\u5174\u594b\u3002\n

\n

\n\u300c\u6211\u4eca\u5929\u53bb\u53c2\u52a0\u62db\u8058\u4f1a\u8ba4\u8bc6\u7684\uff0c\u4ed6\u8bf7\u6211\u5403\u4e86\u987f\u996d\uff0c\u8fd8\u8bf4\u6211\u50cf\u4ed6\u8868\u59b9\uff0c\u4e00\u89c1\u6211\u5c31\u60f3\u5e26\u6211\u56de\u5bb6\u4e0b\u9762\u7ed9\u6211\u5403\u5462\uff0c\u54c8\u54c8\u300d\n

\n

\n\u5b8b\u5f3a\u89c9\u5f97\u4e0d\u53ef\u601d\u8bae\uff0c\u5979\u7adf\u7136\u4f1a\u8fd9\u6837\u968f\u968f\u4fbf\u4fbf\u548c\u964c\u751f\u4eba\u5403\u996d\uff0c\u8fd8\u8fd9\u6837\u4e00\u8138\u5f97\u610f\u7684\u8bf4\u51fa\u6765\u3002\n

\n

\n\u300c\u4ed6\u529d\u544a\u8bf4\u7231\u60c5\u9760\u4e0d\u4f4f\uff0c\u4e0d\u8981\u9677\u5f97\u592a\u6df1\uff0c\u4e0d\u7136\u6700\u7ec8\u53d7\u4f24\u7684\u8fd8\u662f\u81ea\u5df1\u3002\u300d\n

\n

\n\u5b8b\u5f3a\u6709\u70b9\u6012\u4e86\uff1a\u300c\u4ed6\u8c01\u554a\uff1f\u65e2\u7136\u7231\u60c5\u9760\u4e0d\u4f4f\uff0c\u4f60\u8fd8\u6765\u627e\u6211\u5e72\u4ec0\u4e48\uff1f\u300d\n

\n

\n\u9648\u6d01\u6d01\u89c9\u5f97\u83ab\u540d\u5176\u5999\uff0c\u8fd9\u6709\u4ec0\u4e48\u597d\u751f\u6c14\u7684\uff0c\u751a\u81f3\u89c9\u5f97\u6709\u70b9\u59d4\u5c48\uff0c\u8d76\u5fd9\u8bf4\uff1a\u300c\u6211\u5f53\u65f6\u5c31\u53cd\u9a73\u4ed6\u4e86\uff0c\u6211\u8bf4\u6211\u76f8\u4fe1\u6211\u7537\u670b\u53cb\uff01\u300d\n

\n

\n\u5b8b\u5f3a\u6ca1\u597d\u6c14\u7684\u7528\u9f3b\u5b54\u54fc\u4e86\u4e00\u58f0\uff0c\u8868\u793a\u542c\u89c1\u4e86\u3002\n

\n

\n\u300c\u4ed6\u8fd8\u8bf4\uff0c\u6d3e\u516c\u53f8\u7684\u5973\u516c\u5173\u6765\uff0c\u4e00\u5929\u5c31\u53ef\u4ee5\u628a\u4f60\u62ff\u4e0b\u3002\u6211\u53ea\u544a\u8bc9\u4ed6\uff0c\u4e0d\u9700\u8981\u6d3e\u8c01\uff0c\u53cd\u6b63\u6211\u76f8\u4fe1\u6211\u7537\u670b\u53cb\uff01\u300d\n

\n

\n\u9648\u6d01\u6d01\u770b\u5b8b\u5f3a\u8fd8\u6709\u70b9\u751f\u6c14\uff0c\u4f46\u8138\u8272\u5df2\u7ecf\u7f13\u548c\u5f88\u591a\u4e86\uff0c\u4f9d\u504e\u5728\u4ed6\u80a9\u8180\u4e0a\uff0c\u67d4\u58f0\u8bf4\uff1a\u300c\u6211\u4ee5\u540e\u4e0d\u8ddf\u8fd9\u79cd\u4eba\u8bf4\u8bdd\u4e86\uff0c\u539f\u8c05\u6211\u6d89\u4e16\u672a\u6df1\uff01\u300d\n

\n

\n\u4f46\u5b8b\u5f3a\u611f\u89c9\u53d7\u5230\u4e86\u4fae\u8fb1\uff0c\u51b7\u51b7\u7684\u8bf4\uff0c\u300c\u5176\u5b9e\u4f60\u53ef\u4ee5\u8ba9\u4ed6\u6d3e\u5973\u516c\u5173\u6765\uff0c\u770b\u80fd\u4e0d\u80fd\u628a\u6211\u62ff\u4e0b\uff1f\u300d\n

\n

\n\u9648\u6d01\u6d01\u5fd9\u6469\u6332\u7740\u5b8b\u5f3a\u7684\u80cc\u90e8\uff0c\u7740\u6025\u7684\u8fa9\u89e3\uff1a\u300c\u54ce\u5440\uff0c\u4e0d\u751f\u6c14\u4e86\u561b\uff0c\u8fd9\u6b21\u662f\u6211\u4e0d\u5bf9\uff0c\u6211\u4e0d\u8be5\u5750\u4ed6\u7684\u8f66\uff0c\u542c\u4ed6\u8bf4\u8fd9\u4e9b\u6df7\u8d26\u8bdd\u3002\u300d\n

\n

\n\u5b8b\u5f3a\u5374\u4e0d\u4f9d\u4e0d\u9976\uff1a\u300c\u4e8b\u60c5\u505a\u4e86\u5c31\u7b97\u4e86\uff0c\u4f60\u8fd8\u597d\u610f\u601d\u606c\u7740\u8138\u7ed9\u6211\u8bf4\uff0c\u4ec0\u4e48\u5e26\u4f60\u56de\u5bb6\u4e0b\u9762\u5403\uff0c\u4f60\u77e5\u9053\u4ed6\u5728\u5360\u4f60\u4fbf\u5b9c\u5417\uff1f\u300d\n

\n

\n\u300c\u4ec0\u4e48\u5360\u6211\u4fbf\u5b9c\uff1f\u5317\u65b9\u5403\u9762\u5f88\u6b63\u5e38\u554a\uff0c\u5bb6\u91cc\u505a\u987f\u9762\u62db\u5f85\u5ba2\u4eba\u624d\u91cd\u89c6\u554a\uff1f\u300d\uff0c\u9648\u6d01\u6d01\u6025\u7684\u8981\u54ed\u4e86\u3002\n

\n

\n\u300c\u54ce\uff0c\u6211\u600e\u4e48\u548c\u4f60\u8bf4\u5462\uff0c\u7b97\u4e86\uff0c\u6211\u4eec\u5206\u624b\u5427\uff01\u5b9e\u5728\u60f3\u4e0d\u5230\uff0c\u8fd9\u5929\u5e95\u4e0b\u8fd8\u6709\u8fd9\u4e48\u7b28\u7684\u5973\u4eba\u3002\u300d\n

\n

\n\u5b8b\u5f3a\u8fd9\u53e5\u8bdd\u4eff\u4f5b\u662f\u9a8c\u8bc1\u4e86\u5f20\u660e\u7a0b\u7684\u8bdd\uff0c\u9648\u6d01\u6d01\u7b80\u76f4\u4e0d\u613f\u76f8\u4fe1\u81ea\u5df1\u7684\u8033\u6735\uff0c\u8f6c\u8eab\u671d\u6821\u95e8\u53e3\u8d70\u53bb\uff0c\u773c\u6cea\u60c5\u4e0d\u81ea\u7981\u7684\u6d41\u4e0b\u6765\u3002\n

\n

\n\u770b\u9648\u6d01\u6d01\u8fb9\u8d70\u8fb9\u54ed\uff0c\u5b8b\u5f3a\u5012\u89c9\u5f97\u81ea\u5df1\u505a\u7684\u6709\u70b9\u592a\u8fc7\u4e86\uff0c\u5c31\u62c9\u4e86\u62c9\u9648\u6d01\u6d01\u7684\u624b\uff0c\u300c\u5c31\u56de\u53bb\u4e86\uff1f\u8981\u4e0d\u5403\u5b8c\u996d\u518d\u56de\u53bb\u5427\uff1f\u300d\n

\n

\n\u9648\u6d01\u6d01\u7529\u5f00\uff0c\u6ca1\u597d\u6c14\u7684\u8bf4\uff0c\u300c\u90fd\u5206\u624b\u4e86\uff0c\u8fd8\u5403\u4ec0\u4e48\u996d\uff1f\u300d\n

\n

\n\u5c31\u8fd9\u6837\uff0c\u5b8b\u5f3a\u8ddf\u7740\u8d70\u51fa\u6821\u95e8\u53e3\uff0c\u76ee\u9001\u9648\u6d01\u6d01\u5750\u4e0a\u516c\u4ea4\u8f66\uff0c\u7136\u540e\u5782\u5934\u4e27\u6c14\u7684\u56de\u5230\u56fe\u4e66\u9986\u3002\n

\n

\n\u300c\u524d\u4e00\u79d2\u5728\u5929\u5802\uff0c\u540e\u4e00\u79d2\u5728\u5730\u72f1\u3002\u300d\n

\n

\n\u8fd9\u662f\u9648\u6d01\u6d01\u5f53\u665a\u53d1\u7ed9\u5b8b\u5f3a\u7684\u77ed\u4fe1\uff0c\u5b8b\u5f3a\u6ca1\u56de\uff0c\u7b49\u5230\u51cc\u6668\u624d\u56de\u4e86\u4e00\u53e5\uff1a\u300c\u660e\u5929\u6211\u6765\u627e\u4f60\u5427\u300d\u3002\n

\n

\n\u9648\u6d01\u6d01\u5f88\u5feb\u56de\u590d\u4e86\u4e00\u4e2a\u5b57\uff1a\u300c\u597d\u300d\u3002\n

\n

\n\u4e24\u4eba\u5f88\u5feb\u548c\u597d\uff0c\u540e\u6765\u5171\u540c\u7ec4\u5efa\u4e86\u5bb6\u5ead\uff0c\u8bf4\u8d77\u8fd9\u4e2a\u4e8b\u60c5\uff0c\u4e24\u4eba\u90fd\u5f53\u505a\u4e00\u4ef6\u7b11\u8c08\uff0c\u4e3a\u5f7c\u6b64\u5f53\u5e74\u7684\u4e3e\u6b62\u611f\u5230\u597d\u7b11\u3002\n

\n

\n\u8fd9\u4ef6\u4e8b\u60c5\u9010\u6e10\u6de1\u5fd8\u4e86\uff0c\u6240\u4ee5\u5f53\u9648\u6d01\u6d01\u8ba4\u51fa\u773c\u524d\u8fd9\u4e2a\u9762\u8bd5\u81ea\u5df1\u7684\u4eba\u5c31\u662f\u5f53\u5e74\u7684\u5f20\u660e\u7a0b\u65f6\uff0c\u5979\u4e0d\u77e5\u9053\u8be5\u8bf4\u4ec0\u4e48\u3002\n

\n

\n\u5f20\u660e\u7a0b\u7b11\u7740\u8bf4\uff1a\u300c\u600e\u4e48\u6837\uff1f\u4f60\u7684\u7231\u60c5\u7ecf\u53d7\u4f4f\u4e86\u8003\u9a8c\u5417\uff1f\u300d\n

\n

\n\u9648\u6d01\u6d01\u660e\u767d\u4ed6\u7684\u610f\u601d\uff0c\u7406\u4e86\u7406\u5934\u53d1\uff0c\u5f88\u9a84\u50b2\u7684\u8bf4\uff1a\u300c\u6211\u7684\u7231\u60c5\u4e0d\u4f46\u7ecf\u53d7\u4f4f\u4e86\u8003\u9a8c\uff0c\u8fd8\u5f00\u82b1\u7ed3\u679c\u4e86\uff0c\u5b69\u5b50\u90fd\u4e0a\u5b66\u4e86\uff01\u300d\n

\n

\n\u6709\u4e86\u4ee5\u524d\u7684\u4e8b\u60c5\uff0c\u9648\u6d01\u6d01\u6ca1\u6709\u548c\u5f20\u660e\u7a0b\u592a\u591a\u7ea0\u7f20\uff0c\u5306\u5306\u56de\u7b54\u4e86\u51e0\u4e2a\u95ee\u9898\u5c31\u79bb\u5f00\u4e86\uff0c\u5e76\u4e14\u51b3\u5b9a\u81ea\u5df1\u4e0d\u4f1a\u6765\u8fd9\u5bb6\u516c\u53f8\u4e0a\u73ed\u3002\n

\n

\n\u5b8b\u5f3a\u6b63\u5750\u5728\u4e00\u4e2a\u89d2\u843d\u559d\u80e1\u8fa3\u6c64\uff0c\u6bcf\u5929\u9001\u5b8c\u8001\u5a46\u5b69\u5b50\u540e\uff0c\u4ed6\u90fd\u5728\u8fd9\u5bb6\u5c0f\u5e97\u5403\u65e9\u9910\u3002\n

\n

\n\u9648\u6d01\u6d01\u53d1\u6765\u4fe1\u606f\uff0c\u8bf4\u5df2\u7ecf\u5750\u4e0a\u56de\u6765\u7684\u5730\u94c1\u4e86\uff0c\u8ba9\u53bb\u5730\u94c1\u53e3\u63a5\u5979\u3002\n

\n

\n\u5b8b\u5f3a\u5fc3\u60f3\u867d\u7136\u81ea\u5df1\u8fb9\u73a9\u624b\u673a\u8fb9\u5403\u996d\uff0c\u7684\u786e\u6709\u70b9\u6162\uff0c\u4f46\u5979\u4e5f\u56de\u6765\u7684\u592a\u5feb\u4e86\u5427\uff0c\u96be\u9053\u9762\u8bd5\u4e0d\u987a\u5229\uff1f\n

\n

\n\u9648\u6d01\u6d01\u770b\u8d77\u6765\u5fc3\u60c5\u4e0d\u9519\uff0c\u5750\u4e0a\u8f66\u5c31\u628a\u5e7f\u64ad\u5173\u4e86\uff0c\u7528\u624b\u673a\u64ad\u653e\u4e86\u97f3\u4e50\uff0c\u662f\u300a\u96ea\u5c71\u98de\u72d0\u300b\u7684\u4e3b\u9898\u66f2\u300a\u96ea\u4e2d\u60c5\u300b\u3002\n

\n

\n\u5b8b\u5f3a\u6545\u4f5c\u8f7b\u677e\u7684\u95ee\uff1a\u300c\u600e\u4e48\uff1f\u8fd9\u4e48\u5feb\u5c31\u9762\u8bd5\u5b8c\u4e86\uff1f\u300d\n

\n

\n\u9648\u6d01\u6d01\u6ca1\u597d\u6c14\u7684\u8bf4\uff1a\u300c\u54ce\uff0c\u5c31\u662f\u4e00\u4e2a\u5c0f\u516c\u53f8\uff0c\u5173\u952e\u90a3\u9762\u8bd5\u5b98\u8d3c\u7709\u9f20\u773c\uff0c\u4e00\u770b\u5c31\u70e6\u3002\u300d\n

\n

\n\u5b8b\u5f3a\u54c8\u54c8\u4e00\u7b11\uff0c\u95ee\uff1a\u300c\u4f60\u77e5\u9053\u6211\u6bcf\u5929\u5403\u65e9\u9910\u90a3\u4e2a\u8001\u677f\u5a18\u53eb\u4ec0\u4e48\u540d\u5b57\u5417\uff1f\u300d\n

\n

\n\u300c\u53eb\u5565\u540d\u5b57\uff1f\u300d\n

\n

\n\u300c\u7f57\u8273\u8273\u300d\n

\n

\n\u300c\u71d5\u5b50\u7684\u71d5\uff1f\u300d\n

\n

\n\u300c\u7f8e\u8273\u7684\u8273\uff0c\u54c8\u54c8\u3002\u3002\u3002\u300d\n

\n

\n\u8f66\u5b50\u4e00\u8def\u5411\u5357\u75be\u9a70\uff0c\u9648\u6d01\u6d01\u770b\u7a97\u5916\u4e91\u6de1\u98ce\u8f7b\uff0c\u65e9\u4e0a\u90a3\u56e2\u79ef\u96e8\u4e91\u65e9\u5df2\u4e0d\u77e5\u53bb\u5411\u3002\n

\n

\n\u53ef\u89c1\uff0c\u5373\u4f7f\u770b\u89c1\u79ef\u96e8\u4e91\uff0c\u4e5f\u672a\u5fc5\u4f1a\u6709\u96e8\u3002\n

\n
"}, {"title": "\u51e0\u4e2a\u5e38\u7528\u7684Linux\u547d\u4ee4\u4e0e\u95ee\u9898", "url": "/2022/10/18/unzip.html", "content": "None"}, {"title": "\u7b2c\u4e00\u4f4d\u7530\u56ed\u8bd7\u4eba\u9676\u6e0a\u660e", "url": "/2022/10/18/NanChaoGuShiRenWu_01.html", "content": "None"}, {"title": "\u5510\u7384\u5b97\u5728\u4f4d45\u5e74\u5927\u4e8b\u8bb0", "url": "/2022/06/22/TangXuanZong.html", "content": "None"}, {"title": "\u5510\u9ad8\u5b97\u5eb6\u957f\u5b50\u674e\u5fe0\u7684\u574e\u5777\u4eba\u751f", "url": "/2022/06/20/LiZhong.html", "content": "None"}, {"title": "\u5510\u671d\u768420\u4f4d\u7687\u5e1d", "url": "/2022/06/19/TangChaoHuangDiJieShao.html", "content": "None"}, {"title": "\u8bd7\u4eba\u5d14\u98a2\u7684\u6709\u6587\u65e0\u884c", "url": "/2022/05/19/CuiHao.html", "content": "None"}] diff --git a/tags.html b/tags.html index 95f6b0e5..2972e491 100644 --- a/tags.html +++ b/tags.html @@ -105,7 +105,7 @@

标签

diff --git a/tags/201910.html b/tags/201910.html index 6fd15d56..d53bf23f 100644 --- a/tags/201910.html +++ b/tags/201910.html @@ -130,21 +130,21 @@

微信公众号

diff --git a/tags/202005.html b/tags/202005.html index c82a815a..c98318f0 100644 --- a/tags/202005.html +++ b/tags/202005.html @@ -130,21 +130,21 @@

微信公众号

diff --git a/tags/202205.html b/tags/202205.html index aaee8d9d..4229fa25 100644 --- a/tags/202205.html +++ b/tags/202205.html @@ -130,21 +130,21 @@

微信公众号

diff --git a/tags/202206.html b/tags/202206.html index c4c27996..ec59e8c0 100644 --- a/tags/202206.html +++ b/tags/202206.html @@ -130,21 +130,21 @@

微信公众号

diff --git a/tags/202210.html b/tags/202210.html index c1b00ba5..6e3cd5ae 100644 --- a/tags/202210.html +++ b/tags/202210.html @@ -130,21 +130,21 @@

微信公众号

diff --git a/tags/202211.html b/tags/202211.html index fb6e22fe..9b4c32d0 100644 --- a/tags/202211.html +++ b/tags/202211.html @@ -130,21 +130,21 @@

微信公众号

diff --git a/tags/202212.html b/tags/202212.html index c377e3cc..2a8dd75b 100644 --- a/tags/202212.html +++ b/tags/202212.html @@ -130,21 +130,21 @@

微信公众号

diff --git a/tags/202301.html b/tags/202301.html index 1aa0e414..bfeea26d 100644 --- a/tags/202301.html +++ b/tags/202301.html @@ -130,21 +130,21 @@

微信公众号

diff --git a/tags/202302.html b/tags/202302.html index 6e0d07b5..96d4c774 100644 --- a/tags/202302.html +++ b/tags/202302.html @@ -130,21 +130,21 @@

微信公众号

diff --git a/tags/202303.html b/tags/202303.html index 80b7b9f8..f674c40f 100644 --- a/tags/202303.html +++ b/tags/202303.html @@ -130,21 +130,21 @@

微信公众号

diff --git a/tags/202304.html b/tags/202304.html index ddee6112..7fb26a03 100644 --- a/tags/202304.html +++ b/tags/202304.html @@ -130,21 +130,21 @@

微信公众号

diff --git a/tags/202305.html b/tags/202305.html index f8c62c89..e3ecc365 100644 --- a/tags/202305.html +++ b/tags/202305.html @@ -130,21 +130,21 @@

微信公众号

diff --git a/tags/202307.html b/tags/202307.html index d3fc91e9..8525c8a2 100644 --- a/tags/202307.html +++ b/tags/202307.html @@ -130,21 +130,21 @@

微信公众号

diff --git a/tags/202308.html b/tags/202308.html new file mode 100644 index 00000000..4d3762d3 --- /dev/null +++ b/tags/202308.html @@ -0,0 +1,218 @@ + + + + + + + + + 202308 + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+ + + + + + + + + + + + + diff --git "a/tags/C++\345\255\246\344\271\240\344\270\216\345\256\236\350\267\265.html" "b/tags/C++\345\255\246\344\271\240\344\270\216\345\256\236\350\267\265.html" index 77575497..a73ae7e3 100644 --- "a/tags/C++\345\255\246\344\271\240\344\270\216\345\256\236\350\267\265.html" +++ "b/tags/C++\345\255\246\344\271\240\344\270\216\345\256\236\350\267\265.html" @@ -130,21 +130,21 @@

微信公众号

diff --git "a/tags/Linux\346\223\215\344\275\234\344\270\216\347\256\241\347\220\206.html" "b/tags/Linux\346\223\215\344\275\234\344\270\216\347\256\241\347\220\206.html" index daf864e5..80271e7a 100644 --- "a/tags/Linux\346\223\215\344\275\234\344\270\216\347\256\241\347\220\206.html" +++ "b/tags/Linux\346\223\215\344\275\234\344\270\216\347\256\241\347\220\206.html" @@ -130,21 +130,21 @@

微信公众号

diff --git "a/tags/\345\215\227\351\207\216\351\233\206.html" "b/tags/\345\215\227\351\207\216\351\233\206.html" index 3035b772..b5808f51 100644 --- "a/tags/\345\215\227\351\207\216\351\233\206.html" +++ "b/tags/\345\215\227\351\207\216\351\233\206.html" @@ -130,21 +130,21 @@

微信公众号

diff --git "a/tags/\345\244\247\346\225\260\346\215\256\344\270\216\344\272\272\345\267\245\346\231\272\350\203\275.html" "b/tags/\345\244\247\346\225\260\346\215\256\344\270\216\344\272\272\345\267\245\346\231\272\350\203\275.html" index a1db7c91..6c89e3a0 100644 --- "a/tags/\345\244\247\346\225\260\346\215\256\344\270\216\344\272\272\345\267\245\346\231\272\350\203\275.html" +++ "b/tags/\345\244\247\346\225\260\346\215\256\344\270\216\344\272\272\345\267\245\346\231\272\350\203\275.html" @@ -130,21 +130,21 @@

微信公众号

diff --git "a/tags/\346\227\245\350\257\255\345\255\246\344\271\240.html" "b/tags/\346\227\245\350\257\255\345\255\246\344\271\240.html" index 7d04417c..72816855 100644 --- "a/tags/\346\227\245\350\257\255\345\255\246\344\271\240.html" +++ "b/tags/\346\227\245\350\257\255\345\255\246\344\271\240.html" @@ -130,21 +130,21 @@

微信公众号

diff --git "a/tags/\350\247\243\351\207\212\345\231\250\344\270\216\347\274\226\350\257\221\345\231\250.html" "b/tags/\350\247\243\351\207\212\345\231\250\344\270\216\347\274\226\350\257\221\345\231\250.html" index bff12906..5d68fdae 100644 --- "a/tags/\350\247\243\351\207\212\345\231\250\344\270\216\347\274\226\350\257\221\345\231\250.html" +++ "b/tags/\350\247\243\351\207\212\345\231\250\344\270\216\347\274\226\350\257\221\345\231\250.html" @@ -130,21 +130,21 @@

微信公众号

diff --git "a/tags/\351\232\217\347\254\224\346\234\255\350\256\260.html" "b/tags/\351\232\217\347\254\224\346\234\255\350\256\260.html" index e546a04f..58971ee6 100644 --- "a/tags/\351\232\217\347\254\224\346\234\255\350\256\260.html" +++ "b/tags/\351\232\217\347\254\224\346\234\255\350\256\260.html" @@ -108,7 +108,7 @@

随笔札记

@@ -130,21 +130,21 @@

微信公众号