|
CMakeTutorialStep1 2.3.12
|
step1 主程序:读命令行数值、调用 TutorialMath 求平方根并打印。 More...
#include <algorithm>#include <cstddef>#include <cstdlib>#include <functional>#include <iostream>#include <numeric>#include <ostream>#include <string>#include <utility>#include <vector>#include "CMakeTutorialConfig.hxx"#include "ScenarioLog.hxx"#include "TutorialMath.hxx"Classes | |
| struct | hash_Person |
| 人员结构 + std::hash 特化演示(自定义类型可入无序容器)。 More... | |
| class | di_Printer |
| 依赖注入演示:输出接口(构造函数注入进 di_MessageService)。 More... | |
| class | di_MessageService |
| 依赖注入演示:持有 di_Printer 引用,不自行创建依赖。 More... | |
| struct | std::hash< hash_Person > |
Namespaces | |
| namespace | std |
Functions | |
| void | passByValue (int x) |
| 按值传递:形参修改不影响实参。 | |
| void | passByReference (int &x) |
| 按引用传递:函数内修改直接作用于实参。 | |
| void | modifyValue (const int &value) |
| 常量引用传递:只读访问,禁止修改(编译器强制)。 | |
| int | main (int argc, char *argv[]) |
| 程序入口:校验参数 → compute_sqrt → 打印 CMake 注入的宏与版本信息。 | |
| void | log_error (std::string_view msg) |
| 写 ERROR 级日志并触发裁剪 | |
| void | log_info (std::string_view msg) |
| 写 INFO 级日志并触发裁剪 | |
| void | log_sep () |
| 输出分隔线(经 log_info) | |
step1 主程序:读命令行数值、调用 TutorialMath 求平方根并打印。
运行日志经 ScenarioLog 写入 log/exe.log(【不可删除】见 ScenarioLog.hxx/.cxx)。
| void scenario_log::log_error | ( | std::string_view | msg | ) |
写 ERROR 级日志并触发裁剪
| void scenario_log::log_info | ( | std::string_view | msg | ) |
写 INFO 级日志并触发裁剪
| void scenario_log::log_sep | ( | ) |
输出分隔线(经 log_info)
| int main | ( | int | argc, |
| char * | argv[] ) |
程序入口:校验参数 → compute_sqrt → 打印 CMake 注入的宏与版本信息。
| argc | 命令行参数个数 |
| argv | 命令行参数数组(argv[1] 为待开平方的数值) |
| void modifyValue | ( | const int & | value | ) |
常量引用传递:只读访问,禁止修改(编译器强制)。
| value | 只读引用 |
| void passByReference | ( | int & | x | ) |
按引用传递:函数内修改直接作用于实参。
| x | 传入引用 |
| void passByValue | ( | int | x | ) |
按值传递:形参修改不影响实参。
| x | 传入值(副本) |