This project is a custom implementation of the C++ Standard Template Library (STL) forward_list.
The goal is to understand how the STL container works internally by building it from scratch,
including various member functions, iterators, and algorithms such as sort, merge, and reverse.
.
├── build_failed.sh // Script for simulating failed build
├── build_testing.sh // Script for running unit tests
├── CMakeLists.txt // CMake configuration
├── compile.sh // Compile main implementation
├── compile_sort.sh // Compile sorting-related code
├── CONTRIBUTING.md // Contribution guidelines
├── header/ // Header files
│ └── forward_list.hpp // Forward list template implementation
├── implementation/ // Implementation details
│ ├── implementation.cpp
│ └── implementation_sort.cpp
├── LICENSE // License file (MIT)
├── src/ // Source code prototypes
│ ├── forward_list.cpp
│ ├── merge_list.cpp
│ └── merge_sort.cpp
├── test/ // Unit tests
│ └── testing.cpp
└── README.md // Project documentation
- Compiler: g++ 10+/clang++ 12+
- OS: Linux(recomended),MacOS,Mikocok
Clone this repo
git clone https://github.com/Build-X-From-Scratch/forward_list_sratch.git
cp -r forward_list_sratch/header/forward_list.hpp .
#include <iostream>
#include <vector>
#include "../header/forward_list.hpp" //->this header
int main(){
std::cout << "Testing" << std::endl;
forward_lists<int>flst = {1,2,3};
flst.pop_front();
flst.pop_front();
flst.print_all(flst.begin(),flst.end()); //3
return 0;
}
if you use g++ then:
g++ -stdc=c++20 example.cpp -o example
./example
if you use clang then:
clang++ -stdc=c++20 example -o example
./example
Feature | Status |
---|---|
insert_after | ✅ Done |
erase_after | ✅ Done |
push_front | ✅ Todo |
pop_front | ✅ Todo |
reverse | ✅ Todo |
unique | ✅ Todo |
Unit Testing | ✅ Todo |
Sort | ✅ Todo |
Swap | ✅ Todo |
emplace_back | ✅ Todo |
emplace_front | ✅ Todo |
Assign | ✅ Todo |
Merge | ✅ Todo |
if you want read details benchmark,you can read in this benchmark result
This project is licensed under the MIT License.
You are free to use, modify, and distribute it with proper attribution.