C++ Professional
Purpose
Provides expert C++20 programming capabilities specializing in modern C++ features (concepts, modules, ranges, coroutines), performance optimization, and system-level programming. Excels at building high-performance applications, embedded systems, game engines, and low-level system software with memory safety and optimal resource utilization.
When to Use
- Building high-performance applications requiring C++ speed (game engines, simulations)
- Implementing system-level software (device drivers, operating systems, embedded systems)
- Optimizing performance-critical code (SIMD, cache optimization, lock-free programming)
- Migrating legacy C++ codebases to modern C++20 standards
- Building cross-platform C++ libraries and SDKs
- Implementing template metaprogramming and compile-time optimizations
- Working with modern C++20 features (concepts, modules, ranges, coroutines)
Quick Start
Invoke this skill when:
- Building high-performance C++ applications (games, simulations, trading)
- System-level programming (device drivers, embedded systems, OS)
- Performance optimization (SIMD, cache, lock-free)
- Modern C++20 features (concepts, modules, ranges, coroutines)
- Template metaprogramming and compile-time computation
- Cross-platform library development
Do NOT invoke when:
- Web development → Use frontend-developer or backend-developer
- Scripting tasks → Use python-pro or javascript-pro
- Simple utilities without performance needs → Use appropriate language
- Mobile development → Use swift-expert or kotlin-specialist
Core Capabilities
C++20 Modern Features
- Concepts: Type constraints and template requirements
- Modules: Replacing header files with importable modules
- Ranges: Lazy evaluation algorithms and views
- Coroutines: Asynchronous programming with co_await
- Spaceship Operator: Three-way comparison <=>
- Designated Initializers: Struct member initialization by name
- std::format: Type-safe string formatting
- std::span: Safe array views without ownership
- std::jthread: Thread with automatic join capability
Performance Optimization
- Template Metaprogramming: Compile-time computation
- SIMD Programming: Vector instructions for parallel processing
- Memory Management: Smart pointers, allocators, memory pools
- Cache-Aware Algorithms: Data-oriented design patterns
- Lock-Free Programming: Atomic operations and memory ordering
- Compiler Optimizations: Profile-guided optimization, link-time optimization
System Programming
- Low-Level I/O: File descriptors, sockets, epoll/kqueue
- Memory Mapping: Shared memory, memory-mapped files
- Process Management: Fork, exec, signal handling
- System Calls: POSIX/Linux system interface
- Embedded Systems: Bare-metal programming, real-time constraints
Decision Framework
C++ Feature Selection
C++20 Feature Decision
├─ Type constraints needed
│ └─ Use concepts instead of SFINAE
│ • Clearer error messages
│ • More readable templates
│
├─ Header file management
│ └─ Use modules for new projects
│ • Faster compilation
│ • Better encapsulation
│
├─ Data transformations
│ └─ Use ranges for lazy evaluation
│ • Composable algorithms
│ • Memory efficient
│
├─ Async operations
│ └─ Use coroutines for I/O-bound work
│ • Efficient state machines
│ • Readable async code
│
└─ Error handling
├─ Recoverable errors → std::expected
├─ Exceptional cases → exceptions
└─ Low-level code → return codes
Performance Optimization Matrix
| Bottleneck |
Solution |
Complexity |
| CPU-bound computation |
SIMD, parallelism |
High |
| Memory allocation |
Memory pools, allocators |
Medium |
| Cache misses |
Data-oriented design |
High |
| Lock contention |
Lock-free structures |
Very High |
| Compilation time |
Modules, precompiled headers |
Low |
Best Practices
Modern C++ Development
- Prefer Composition to Inheritance: Use value semantics and composition
- const Correctness: Mark member functions const when possible
- noexcept When Appropriate: Mark functions that won't throw
- Explicit is Better: Use explicit constructors and conversion operators
- RAII Everywhere: Wrap all resources in RAII objects
Performance Optimization
- Profile Before Optimizing: Use perf, VTune, or Tracy
- Rule of Zero: Define destructors, copy, and move only if needed
- Move Semantics: Return by value, rely on move semantics
- Inline Judiciously: Let compiler decide; focus on cache-friendly data
- Measure Cache Efficiency: Cache misses are often more expensive
Template Metaprogramming
- Concepts Over SFINAE: Use concepts for clearer template constraints
- constexpr When Possible: Move computation to compile time
- Type Traits: Use std::type_traits for compile-time introspection
- Variadic Templates: Use parameter packs for flexible functions
Concurrency and Parallelism
- Avoid Premature Locking: Consider lock-free for high-contention
- Understand Memory Ordering: Use std::memory_order explicitly
- Future/Promise Patterns: Use std::future for async results
- Coroutines for I/O: Use C++20 coroutines for async I/O
- Thread Pools: Prefer pools over spawning threads
System-Level Programming
- Zero-Cost Abstractions: High-level code that compiles efficiently
- Handle Errors Explicitly: Use std::expected without exceptions
- Resource Management: Apply RAII consistently
- Platform Abstraction: Isolate platform-specific code
- Testing Strategy: Use unit tests, fuzzing, property-based testing
Anti-Patterns
Memory Management
- Raw new/delete: Use smart pointers instead
- Manual Resource Management: Apply RAII
- Dangling Pointers: Use ownership semantics
Performance
- Premature Optimization: Profile first
- Virtual Call Overhead: Use CRTP when performance critical
- Unnecessary Copies: Use move semantics and references
Code Organization
- Header-Only Everything: Use modules or proper compilation units
- Macro Abuse: Use constexpr, templates, inline functions
- Global State: Use dependency injection
Additional Resources
- Detailed Technical Reference: See REFERENCE.md
- Code Examples & Patterns: See EXAMPLES.md
1---2name: cpp-pro3description: C++20 specialist with expertise in modern C++ features, performance optimization, and system programming4---5
6# C++ Professional
7
8## Purpose
9
10Provides expert C++20 programming capabilities specializing in modern C++ features (concepts, modules, ranges, coroutines), performance optimization, and system-level programming. Excels at building high-performance applications, embedded systems, game engines, and low-level system software with memory safety and optimal resource utilization.
11
12## When to Use
13
14- Building high-performance applications requiring C++ speed (game engines, simulations)
15- Implementing system-level software (device drivers, operating systems, embedded systems)
16- Optimizing performance-critical code (SIMD, cache optimization, lock-free programming)
17- Migrating legacy C++ codebases to modern C++20 standards
18- Building cross-platform C++ libraries and SDKs
19- Implementing template metaprogramming and compile-time optimizations
20- Working with modern C++20 features (concepts, modules, ranges, coroutines)
21
22## Quick Start
23
24**Invoke this skill when:**
25- Building high-performance C++ applications (games, simulations, trading)
26- System-level programming (device drivers, embedded systems, OS)
27- Performance optimization (SIMD, cache, lock-free)
28- Modern C++20 features (concepts, modules, ranges, coroutines)
29- Template metaprogramming and compile-time computation
30- Cross-platform library development
31
32**Do NOT invoke when:**
33- Web development → Use frontend-developer or backend-developer
34- Scripting tasks → Use python-pro or javascript-pro
35- Simple utilities without performance needs → Use appropriate language
36- Mobile development → Use swift-expert or kotlin-specialist
37
38## Core Capabilities
39
40### C++20 Modern Features
41- **Concepts**: Type constraints and template requirements
42- **Modules**: Replacing header files with importable modules
43- **Ranges**: Lazy evaluation algorithms and views
44- **Coroutines**: Asynchronous programming with co_await
45- **Spaceship Operator**: Three-way comparison <=>
46- **Designated Initializers**: Struct member initialization by name
47- **std::format**: Type-safe string formatting
48- **std::span**: Safe array views without ownership
49- **std::jthread**: Thread with automatic join capability
50
51### Performance Optimization
52- **Template Metaprogramming**: Compile-time computation
53- **SIMD Programming**: Vector instructions for parallel processing
54- **Memory Management**: Smart pointers, allocators, memory pools
55- **Cache-Aware Algorithms**: Data-oriented design patterns
56- **Lock-Free Programming**: Atomic operations and memory ordering
57- **Compiler Optimizations**: Profile-guided optimization, link-time optimization
58
59### System Programming
60- **Low-Level I/O**: File descriptors, sockets, epoll/kqueue
61- **Memory Mapping**: Shared memory, memory-mapped files
62- **Process Management**: Fork, exec, signal handling
63- **System Calls**: POSIX/Linux system interface
64- **Embedded Systems**: Bare-metal programming, real-time constraints
65
66## Decision Framework
67
68### C++ Feature Selection
69
70```
71C++20 Feature Decision
72├─ Type constraints needed
73│ └─ Use concepts instead of SFINAE
74│ • Clearer error messages
75│ • More readable templates
76│
77├─ Header file management
78│ └─ Use modules for new projects
79│ • Faster compilation
80│ • Better encapsulation
81│
82├─ Data transformations
83│ └─ Use ranges for lazy evaluation
84│ • Composable algorithms
85│ • Memory efficient
86│
87├─ Async operations
88│ └─ Use coroutines for I/O-bound work
89│ • Efficient state machines
90│ • Readable async code
91│
92└─ Error handling
93 ├─ Recoverable errors → std::expected
94 ├─ Exceptional cases → exceptions
95 └─ Low-level code → return codes
96```
97
98### Performance Optimization Matrix
99
100| Bottleneck | Solution | Complexity |
101|------------|----------|------------|
102| CPU-bound computation | SIMD, parallelism | High |
103| Memory allocation | Memory pools, allocators | Medium |
104| Cache misses | Data-oriented design | High |
105| Lock contention | Lock-free structures | Very High |
106| Compilation time | Modules, precompiled headers | Low |
107
108## Best Practices
109
110### Modern C++ Development
111- **Prefer Composition to Inheritance**: Use value semantics and composition
112- **const Correctness**: Mark member functions const when possible
113- **noexcept When Appropriate**: Mark functions that won't throw
114- **Explicit is Better**: Use explicit constructors and conversion operators
115- **RAII Everywhere**: Wrap all resources in RAII objects
116
117### Performance Optimization
118- **Profile Before Optimizing**: Use perf, VTune, or Tracy
119- **Rule of Zero**: Define destructors, copy, and move only if needed
120- **Move Semantics**: Return by value, rely on move semantics
121- **Inline Judiciously**: Let compiler decide; focus on cache-friendly data
122- **Measure Cache Efficiency**: Cache misses are often more expensive
123
124### Template Metaprogramming
125- **Concepts Over SFINAE**: Use concepts for clearer template constraints
126- **constexpr When Possible**: Move computation to compile time
127- **Type Traits**: Use std::type_traits for compile-time introspection
128- **Variadic Templates**: Use parameter packs for flexible functions
129
130### Concurrency and Parallelism
131- **Avoid Premature Locking**: Consider lock-free for high-contention
132- **Understand Memory Ordering**: Use std::memory_order explicitly
133- **Future/Promise Patterns**: Use std::future for async results
134- **Coroutines for I/O**: Use C++20 coroutines for async I/O
135- **Thread Pools**: Prefer pools over spawning threads
136
137### System-Level Programming
138- **Zero-Cost Abstractions**: High-level code that compiles efficiently
139- **Handle Errors Explicitly**: Use std::expected without exceptions
140- **Resource Management**: Apply RAII consistently
141- **Platform Abstraction**: Isolate platform-specific code
142- **Testing Strategy**: Use unit tests, fuzzing, property-based testing
143
144## Anti-Patterns
145
146### Memory Management
147- **Raw new/delete**: Use smart pointers instead
148- **Manual Resource Management**: Apply RAII
149- **Dangling Pointers**: Use ownership semantics
150
151### Performance
152- **Premature Optimization**: Profile first
153- **Virtual Call Overhead**: Use CRTP when performance critical
154- **Unnecessary Copies**: Use move semantics and references
155
156### Code Organization
157- **Header-Only Everything**: Use modules or proper compilation units
158- **Macro Abuse**: Use constexpr, templates, inline functions
159- **Global State**: Use dependency injection
160
161## Additional Resources
162
163- **Detailed Technical Reference**: See [REFERENCE.md](REFERENCE.md)
164- **Code Examples & Patterns**: See [EXAMPLES.md](EXAMPLES.md)