A header-only C++20 library reimplementing core Standard Library components from first principles, including a dynamic array (Vector<T>), hash table (HashMap<K,V>), smart pointers (UniquePtr<T>, SharedPtr<T>), and a fixed-block memory pool allocator.
- Reimplemented
Vector<T>with manual memory management and move-aware reallocation - Built a separate-chaining
HashMap<K,V>with automatic rehashing - Implemented
UniquePtr<T>and reference-countedSharedPtr<T> - Designed a fixed-block
MemoryPoolallocator for fast small-object allocation - Header-only C++20 library
- Unit tested and benchmarked
- AddressSanitizer and UBSan clean
| Component | Description |
|---|---|
Vector<T> |
Dynamic contiguous array with amortized O(1) insertion |
HashMap<K,V> |
Hash table using separate chaining |
UniquePtr<T> |
Exclusive ownership smart pointer |
SharedPtr<T> |
Reference-counted smart pointer |
MemoryPool |
Fixed-block allocator with free-list management |
cpp-mini-stl/
├── CMakeLists.txt
├── README.md
├── include/
│ └── mini/
│ ├── vector.hpp
│ ├── hash_map.hpp
│ ├── unique_ptr.hpp
│ ├── shared_ptr.hpp
│ └── memory_pool.hpp
├── src/
│ └── main.cpp
├── tests/
│ └── test_cases.cpp
├── benchmarks/
│ └── benchmark.cpp
├── docs/
│ └── architecture.md
└── design.md
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -jctest --test-dir build#include <mini/vector.hpp>
#include <mini/hash_map.hpp>
#include <mini/unique_ptr.hpp>
#include <iostream>
int main() {
mini::Vector<int> numbers;
numbers.push_back(10);
numbers.push_back(20);
numbers.push_back(30);
mini::HashMap<std::string, int> scores;
scores["alice"] = 95;
scores["bob"] = 88;
mini::UniquePtr<int> value(new int(42));
std::cout << "Vector size: " << numbers.size() << '\n';
std::cout << "Alice: " << scores["alice"] << '\n';
std::cout << "Value: " << *value << '\n';
return 0;
}./build/benchmarks/benchmarkExample results:
| Benchmark | Result |
|---|---|
| MemoryPool Allocation (64B) | 8.4× faster than malloc |
| Vector Push Back | Measured |
| HashMap Lookup | Measured |
| SharedPtr Creation | Measured |
docs/architecture.md— implementation details and architecturedesign.md— design decisions and tradeoffs
- C++20
- CMake 3.20+
MIT License