From a4ff4789107a2044f5019d9cf6101dfd12881e1b Mon Sep 17 00:00:00 2001 From: gitee-bot Date: Sun, 25 Jan 2026 08:29:49 +0000 Subject: [PATCH] Add README.md --- README.en.md | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 216 insertions(+) create mode 100644 README.en.md create mode 100644 README.md diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000..53ba00f --- /dev/null +++ b/README.en.md @@ -0,0 +1,107 @@ +# C++ Notebook + +This is a C++ learning notebook project that covers the core features and advanced usage of modern C++. The project demonstrates various C++ concepts and techniques through numerous code examples, making it an excellent reference for learning C++. + +## Project Features + +- **Comprehensive Content**: Covers multiple topics including templates, memory management, concurrency, STL, and more +- **Example-Driven**: Each topic includes runnable code examples +- **Progressive Learning**: Progresses from basic to advanced concepts step by step +- **Chinese Comments**: Both code and documentation include Chinese annotations for easier understanding + +## Directory Structure + +``` +cpp-notebook/ +├── alias/ # Alias Template +├── allocator/ # Memory Allocator +├── complex/ # Implementation of Complex Class and String Class +├── const_none_const/ # const and non-const Member Functions +├── cpp_memory_management/ # C++ Memory Management Mechanisms +├── decltype/ # decltype Usage +├── deque/ # deque Container Examples +├── for_each/ # STL Algorithm Examples +├── inherit/ # Inheritance Examples +├── lambda/ # Lambda Expressions +├── new_delete_reload/ # Overloading operator new/delete +├── new_handler/ # Out-of-Memory Handling +├── partial_spacialization/ # Partial Specialization +├── reference_wrapper/ # reference_wrapper Usage +├── reload_new_delete/ # Reloading new/delete +├── rvalue_reference/ # Rvalue References and Perfect Forwarding +├── template_method/ # Template Method Pattern +├── template_spacialization/ # Template Specialization +├── thread_conmunication/ # Thread Communication +├── trait/ # Type Traits and Iterators +├── tuple/ # tuple Implementation +├── variadic/ # Variadic Templates +└── variadic_template/ # Variadic Template Examples +``` + +## Main Content + +### Templates +- **Template Specialization**: Specializing function and class templates +- **Partial Specialization**: Partially specializing for pointer types +- **Variadic Templates**: Expanding parameter packs using variadic templates +- **Alias Templates**: Defining type aliases using `using` + +### Memory Management +- **Memory Management Mechanisms**: Deep understanding of `new` and `delete` +- **Class-Specific Allocators**: Custom memory allocation strategies for specific classes +- **Global/Class Overloading**: Overloading global or class-specific `operator new/delete` +- **Placement New**: Using placement `new` expressions + +### Concurrent Programming +- **Thread Examples**: Basic thread creation and usage +- **Asynchronous Operations**: Usage of `std::async` +- **Exception Handling**: Exception propagation within threads + +### Practical Features +- **Lambda Expressions**: Anonymous functions and capture mechanisms +- **Rvalue References**: Move semantics and perfect forwarding +- **decltype**: Type deduction +- **tuple**: Implementation and usage of tuples +- **reference_wrapper**: Reference wrapper + +## Compilation and Execution + +### Environment Requirements +- C++11 or higher compiler +- CMake or Make build tools + +### Compilation Examples + +Navigate to the respective directory and compile: + +```bash +# Enter the example directory +cd alias +g++ -std=c++11 -o main main.cpp +./main + +# Or use CMake +mkdir build && cd build +cmake .. +make +``` + +## Contribution Guidelines + +Contributions via Issues and Pull Requests are welcome. You can contribute by: + +- Adding more examples +- Improving documentation +- Fixing code bugs +- Adding test cases + +## License + +This project is licensed under the MIT License. See the LICENSE file for details. + +## References + +- C++ Primer +- Effective C++ +- Effective Modern C++ +- C++ Standard Library Documentation \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..9d8658a --- /dev/null +++ b/README.md @@ -0,0 +1,109 @@ + + +# C++ Notebook + +这是一个 C++ 学习笔记项目,涵盖了现代 C++ 的核心特性和高级用法。项目通过大量的代码示例来演示 C++ 的各种概念和技巧,适合作为 C++ 学习的参考资料。 + +## 项目特点 + +- **内容全面**:涵盖模板、内存管理、并发、STL 等多个主题 +- **示例驱动**:每个主题都配有可运行的代码示例 +- **循序渐进**:从基础到高级,逐步深入 +- **中文注释**:代码和文档均有中文说明,便于理解 + +## 目录结构 + +``` +cpp-notebook/ +├── alias/ # 别名模板(Alias Template) +├── allocator/ # 内存分配器 +├── complex/ # 复数类和字符串类实现 +├── const_none_const/ # const 与非 const 成员函数 +├── cpp_memory_management/ # C++ 内存管理机制 +├── decltype/ # decltype 用法 +├── deque/ # deque 容器示例 +├── for_each/ # STL 算法示例 +├── inherit/ # 继承相关示例 +├── lambda/ # Lambda 表达式 +├── new_delete_reload/ # new/delete 操作符重载 +├── new_handler/ # 内存不足处理 +├── partial_spacialization/ # 偏特化 +├── reference_wrapper/ # reference_wrapper 用法 +├── reload_new_delete/ # 重新加载 new/delete +├── rvalue_reference/ # 右值引用与完美转发 +├── template_method/ # 模板方法模式 +├── template_spacialization/ # 模板特化 +├── thread_conmunication/ # 线程通信 +├── trait/ # 类型特性和迭代器 +├── tuple/ # tuple 实现 +├── variadic/ # 变长参数模板 +└── variadic_template/ # 变长模板示例 +``` + +## 主要内容 + +### 模板相关 +- **模板特化**:特化函数模板和类模板 +- **偏特化**:对指针类型进行偏特化 +- **变长模板**:使用可变参数模板实现参数包展开 +- **别名模板**:使用 using 定义类型别名 + +### 内存管理 +- **内存管理机制**:深入理解 new/delete +- **类专属分配器**:为特定类自定义内存分配策略 +- **全局/类重载**:重载全局或类的 operator new/delete +- **替换 new 表达式**:使用 placement new + +### 并发编程 +- **线程示例**:基本线程创建和使用 +- **异步操作**:std::async 的使用 +- **异常处理**:线程中的异常传播 + +### 实用特性 +- **Lambda 表达式**:匿名函数和捕获机制 +- **右值引用**:移动语义和完美转发 +- **decltype**:类型推导 +- **tuple**:元组实现和使用 +- **reference_wrapper**:引用包装器 + +## 编译运行 + +### 环境要求 +- C++11 或更高版本编译器 +- CMake 或 Make 构建工具 + +### 编译示例 + +进入相应目录编译: + +```bash +# 进入示例目录 +cd alias +g++ -std=c++11 -o main main.cpp +./main + +# 或者使用 CMake +mkdir build && cd build +cmake .. +make +``` + +## 贡献指南 + +欢迎提交 Issue 和 Pull Request 来完善这个项目。你可以通过以下方式贡献: + +- 补充更多示例 +- 完善文档说明 +- 修复代码错误 +- 添加测试用例 + +## 许可证 + +本项目采用 MIT 许可证,详情请参阅 LICENSE 文件。 + +## 参考资料 + +- C++ Primer +- Effective C++ +- Modern Effective C++ +- C++ 标准库文档 \ No newline at end of file -- Gitee