File tree 37 files changed +143
-74
lines changed
37 files changed +143
-74
lines changed Original file line number Diff line number Diff line change 1
1
# Professional C++ 5th edition answer
2
2
3
3
这是对于《Professional C++》第五版的一些自己做的答案(可能借鉴了一点点原书答案),采用MSVC最新支持的C++语法。
4
+
5
+ ## MSVC
6
+
7
+ 主要使用,均可运行。
8
+
9
+ ## GCC
10
+
11
+ 不支持
12
+
13
+ ## Clang
14
+
15
+ 简单测试,未完全覆盖,需要自行编译安装 libc++ module(libstdc++ 没有 module)。
16
+
17
+ 过程为:
18
+
19
+ ``` shell
20
+ git clone https://github.com/llvm/llvm-project.git
21
+ cd llvm-project
22
+ mkdir build
23
+ cmake -G Ninja -S runtimes -B build -DLIBCXX_ENABLE_STD_MODULES=ON -DLLVM_ENABLE_RUNTIMES=" libcxx;libcxxabi;libunwind"
24
+ ninja -C build
25
+ ```
26
+
27
+ 记 ` build ` 文件夹为 ` <build> `
28
+
29
+
30
+ 编译指令为在项目同级文件夹输入:
31
+
32
+ ``` shell
33
+ mkdir build
34
+ cmake -G Ninja -S . -B build -DCMAKE_CXX_COMPILER=< path-to-clang> -DLIBCXX_BUILD=< build>
35
+ ninja -C build
36
+ build/main
37
+ ```
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (1-1)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
10
- FILE_SET all_my_modules TYPE CXX_MODULES FILES
11
10
main.cpp
11
+ PRIVATE
12
+ FILE_SET all_my_modules TYPE CXX_MODULES FILES
12
13
employee.cppm
13
14
)
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (1-2)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (1-3)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (1-4)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (1-5)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (1-6)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (10-1)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (10-2)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (10-4)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (10-3)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (11-1)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (11-2)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (11-3)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (11-4)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (12-1)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (12-2)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (12-3)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (12-4)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (12-5)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (12-6)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (13-1)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (13-2)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (2-1)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (2-2)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (2-3)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (2-4)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (7-3)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (8-1)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
Original file line number Diff line number Diff line change 1
1
CMAKE_MINIMUM_REQUIRED (VERSION 3.25)
2
2
3
- include ("../../module.cmake" )
4
-
5
3
project (8-2)
6
4
5
+ include ("../../module.cmake" )
6
+
7
7
add_executable (${CMAKE_PROJECT_NAME} )
8
8
target_sources (${CMAKE_PROJECT_NAME}
9
9
PUBLIC
You can’t perform that action at this time.
0 commit comments