@@ -30,6 +30,7 @@ This project serves as both a learning resource and a reference implementation f
30
30
- ** Type Safety** : Concept-based constraints preventing common programming errors
31
31
- ** Performance Tools** : Built-in timing utilities and benchmark framework
32
32
- ** Error Handling** : Multiple error handling strategies (exceptions, ` Result ` type, ` std::expected ` )
33
+ - ** Python Bindings** : Complete pybind11 integration with modern Python 3.13 features
33
34
34
35
### Code Quality & Development
35
36
@@ -92,6 +93,7 @@ This project demonstrates practical applications of:
92
93
- ** C++23 compatible compiler** ([ Clang] 20+ / [ GCC] 14+)
93
94
- ** [ CMake] 3.23+**
94
95
- ** [ Ninja] build system** (required for CMake - faster builds than Make)
96
+ - ** Python 3.13+** (optional, for Python bindings)
95
97
96
98
It's recommended to use a development container for the best development experience.
97
99
See [ ` .devcontainer/README.md ` ] ( .devcontainer/README.md ) for more details.
@@ -134,6 +136,13 @@ cmake --build --preset release
134
136
ctest --preset release
135
137
```
136
138
139
+ #### Build Python bindings (optional)
140
+
141
+ ``` bash
142
+ cmake --preset release -DBUILD_PYTHON_BINDINGS=ON
143
+ cmake --build --preset release
144
+ ```
145
+
137
146
### CMake Presets
138
147
139
148
This project uses CMake presets for streamlined build configuration.
@@ -189,7 +198,14 @@ cmake --workflow --preset release-workflow # Complete release cycle
189
198
190
199
### Build Options
191
200
192
- See [ ` cmake/README.md ` ] ( cmake/README.md#options ) for available build options.
201
+ | Option | Description | Default |
202
+ | -------------------------| ------------------------------------| -----------------------|
203
+ | ` BUILD_TESTS ` | Build test suite | ` ON ` (main project) |
204
+ | ` BUILD_EXAMPLES ` | Build example applications | ` ON ` (main project) |
205
+ | ` BUILD_PYTHON_BINDINGS ` | Build Python bindings with pybind11| ` OFF ` |
206
+ | ` ENABLE_WARNINGS ` | Enable compiler warnings | ` ON ` |
207
+
208
+ See [ ` cmake/README.md ` ] ( cmake/README.md#options ) for additional build options.
193
209
194
210
### Pre-commit Setup (Recommended)
195
211
@@ -256,6 +272,33 @@ auto main() -> int {
256
272
}
257
273
```
258
274
275
+ ### Python Usage
276
+
277
+ ``` python
278
+ from cpp_features import shapes, containers, algorithms
279
+
280
+ # Create and use shapes
281
+ circle = shapes.create_shape(" circle" , 5.0 )
282
+ rectangle = shapes.create_shape(" rectangle" , 4.0 , 3.0 )
283
+
284
+ print (f " Circle area: { circle.get_area():.2f } " )
285
+ print (f " Rectangle area: { rectangle.get_area():.2f } " )
286
+
287
+ # Use enhanced containers
288
+ container = containers.create_container([1 , 3 , 2 , 5 , 4 ])
289
+ algorithms.sort_inplace(container)
290
+ print (f " Sorted: { list (container)} " )
291
+
292
+ # Functional programming with modern Python features
293
+ from cpp_features.algorithms import functional_chain
294
+
295
+ result = (functional_chain([1 , 2 , 3 , 4 , 5 , 6 ])
296
+ .filter(lambda x : x % 2 == 0 )
297
+ .map(lambda x : x * x)
298
+ .collect())
299
+ print (f " Even squares: { result} " ) # [4, 16, 36]
300
+ ```
301
+
259
302
## 📁 Project Structure
260
303
261
304
``` text
@@ -266,6 +309,16 @@ cpp-demo-project/
266
309
│ ├── launch.json # VS Code launch configuration
267
310
│ ├── settings.json # VS Code settings
268
311
│ └── tasks.json # VS Code tasks
312
+ ├── binding/ # Python bindings using pybind11
313
+ │ ├── CMakeLists.txt # Python bindings build configuration
314
+ │ ├── cpp_features.cpp # Main pybind11 module
315
+ │ ├── shapes_binding.cpp # Shapes module bindings
316
+ │ ├── containers_binding.cpp # Containers module bindings
317
+ │ ├── algorithms_binding.cpp # Algorithms module bindings
318
+ │ ├── exceptions_binding.cpp # Exceptions module bindings
319
+ │ ├── memory_binding.cpp # Memory module bindings
320
+ │ ├── timing_binding.cpp # Timing module bindings
321
+ │ └── random_binding.cpp # Random module bindings
269
322
├── build/ # Build output (generated by CMake)
270
323
│ ├── debug/ # Debug build output
271
324
│ ├── release/ # Release build output
@@ -286,6 +339,15 @@ cpp-demo-project/
286
339
│ ├── random/ # Type-safe random number generation
287
340
│ ├── shapes/ # Polymorphic shapes with factory functions
288
341
│ └── timing/ # Performance measurement and benchmarking
342
+ ├── python/ # Python wrapper modules
343
+ │ ├── __init__.py # Package initialization
344
+ │ ├── shapes.py # Enhanced shapes module with Python 3.13 features
345
+ │ ├── containers.py # Enhanced containers module
346
+ │ ├── algorithms.py # Functional programming utilities
347
+ │ ├── exceptions.py # Result types and error handling
348
+ │ ├── memory.py # RAII and resource management
349
+ │ ├── timing.py # Benchmarking and timing utilities
350
+ │ └── random.py # Enhanced random number generation
289
351
├── src/ # Source implementation files
290
352
│ ├── CMakeLists.txt # Components configuration
291
353
│ └── [mirrors include structure]
0 commit comments