C++ Custom Vector (System-Level Design)
A production-grade implementation of std::vector focusing on Allocator Type Traits, the Rule of 5, and Strong Exception Guarantees. Designed to handle OS-level memory constraints and complex resource ownership.
The Problem
Standard dynamic arrays often fail to separate allocation from construction, leading to severe performance penalties when dealing with non-trivial objects. Furthermore, naive reallocations can corrupt system state if an exception is thrown mid-copy.
Allocator Paradigm
Uses std::allocator_traits to meticulously decouple raw memory allocation from object initialization, preventing default-constructor overhead.
Exception Safety
During reallocation, if an object throws, the buffer strictly rolls back. Implements std::move_if_noexcept to fall back to copy-semantics for risky types.
The Rule of 5
Strictly enforces Destructor, Copy/Move Constructors, and Copy/Move Assignments via the idiomatic copy-and-swap technique to ensure leak-free operations.
Iterator Compatibility
Provides `begin()`, `end()`, `cbegin()`, and `cend()` pointers satisfying requirements for range-based for-loops and standard library `<algorithm>` headers.