How andonys24/rule-of-five-cpp works
Project type and purpose
• This is a small C++ “demo” / library project illustrating the Rule of Five via a template class Matrix<T>.
• There is one core component (Matrix), a driver (main.cpp) that exercises copy/move operations, and a CMake build script.
File structure
• Top level:
• CMakeLists.txt → build orchestration
• README.md → description
• includes/Matrix.hpp → header-only template class
• src/main.cpp → demo client
• No separate “frontend” or “backend”—it’s a single binary with an embedded library.
README for additional insights
• Confirms purpose: showcase five special member functions (ctor copy, op= copy, ctor move, op= move, dtor).
• No external services, no databases, purely in-process memory management.
a. Main components
• Build System (CMake)
• Matrix<T> class (manages dynamic 2D array)
• Dynamic Memory Resource
• Demo Client (main)
b. Relationships / interactions
• CMake → builds main binary, compiles Matrix.hpp and main.cpp
• Demo Client → instantiates Matrix<int>, invokes ctor, copy, move, dtor
• Matrix<T> → allocates/releases raw memory block (new[] / delete[])
c. Architectural patterns / design principles
• RAII (Resource Acquisition Is Initialization)
• Rule of Five enforcing exception safety and correct ownership transfer
• Header-only template providing inline behavior
d. Key technologies
• C++17 (or later)
• CMake for configuration & build
• Standard library (std::exception for out-of-range)