Implement a tiny STL in C++11.
A lab to implement STL.
It is recommended that you compare the sigstl and stlport implementations.
You can watch this video and this book.
The following presentation shows the file you will implement and the corresponding test file, and you can modify the test/cppuint/cppunit_unitl.h
file and CMakeLists.txt
to open the corresponding test file.
Note the these file have the same names as the corresponding file in the two source implementations for your reference.
The most important thing is to understand generic programming.
-
stl_allocator
memory management, imitatingsigstl
, implementing memory pools.- File:
src/stl_alloc.h
- Test:
test/allocator_test.cpp
- File:
-
auto_ptr
implementing the simplest smart pointer.- File:
src/memory.h
- Test:
test/memory_test.cpp
- File:
-
type_traits
getting started whit the concept of generic procgramming.- File:
src/type_traits.h
- Test:
test/type_traits_test.cpp
- File:
-
global constructor and destructor
- File:
src/stl_construct.h
- File:
-
iterator_traits
base iterator- File:
src/stl_iterator_base.h
- File:
-
[algorithm function] -> copy & fill function
iterator
+type_traits
generic programming- File:
src/stl_algobase.h
- File:
-
uninitialized_[copy/fill/fill_n]
, copy/fill + constructor- File:
src/stl_uninitialized.h
- File:
-
_Alloc_traits
encapsulation provides a uniform interface to cccontainers for both allocators that need to be instantiated and those that do not.-
File:
src/stl_alloc.h
-
This is not in the book&video, you need to look at the code to understand it yourself. You can implement it once for echo container, like in
sgistl
, or you can implement a unified interface, which is how i did it.
-
-
iterator
for the simple iterator is wrapped again, mainly the implementation of the reverse iterator.- File:
src/stl_iterator.h
- File:
-
vector
First container!!!- File:
src/stl_vector.h
- Test:
test/vector_test.h
- File:
-
list
-
hash_map
/hash_set
-
tree