Mini-STL
A minimal implementation of the C++ Standard Template Library built for learning. This project includes implementations of vector, string, map, and smart pointers, all built from scratch to understand the internals of these fundamental data structures.
Overview
The STL is one of the most elegant pieces of software ever written. Its generic programming paradigm, using templates to create type-safe containers and algorithms, revolutionized how we write C++ code.
By implementing my own versions of these containers, I gained deep insight into memory management, iterator design, exception safety guarantees, and the careful attention to detail required for production-quality libraries.
Implemented Containers
mini::vector
Dynamic array with amortized O(1) push_back, custom allocator support, and strong exception safety guarantee.
mini::string
Small string optimization (SSO), copy-on-write semantics, and full iterator support for efficient string handling.
mini::map
Red-black tree implementation with O(log n) lookup, insertion, and deletion. Full bidirectional iterator support.
Smart Pointers
unique_ptr and shared_ptr with custom deleters, make_unique/make_shared helpers, and proper move semantics.
Technical Highlights
Exception Safety: All containers provide the strong exception guarantee where possible. Operations either succeed completely or leave the container unchanged. This required careful use of RAII and copy-and-swap idioms.
Iterator Design: Each container implements proper iterator categories (random-access for vector, bidirectional for map) with all required operators and type traits for STL algorithm compatibility.
Memory Management: The vector uses a growth factor of 1.5x (rather than 2x) to better balance memory usage and reallocation frequency. The string implementation uses SSO for strings up to 15 characters.
The red-black tree implementation was particularly challenging - getting the rotation and recoloring logic correct required extensive testing with property-based tests.
Tech Stack
What I Learned
This project deepened my understanding of C++ template metaprogramming, SFINAE (Substitution Failure Is Not An Error), and the complexities of writing generic, reusable code. I learned why certain design decisions were made in the standard library.
Writing comprehensive tests for edge cases taught me the importance of property-based testing and fuzzing for data structure implementations.