This project was written as part of 42 curriculum.
The main goal is to implement the following containers from the C++ standard library:
We had to follow the specifications from the C++98 standard.
๐ก See the subject for more details.
- Clang or GCC
- ๐ก If you want to use GCC, you will have to change the
CXX
variable in the Makefile tog++
.
- ๐ก If you want to use GCC, you will have to change the
- Cpputest
The source code is located in the inc directory as a header-only library.
All classes and functions are in the ft
namespace.
The test suite is located in the test directory.
In order to compare the results, a variable named NAMESPACE
is defined in the Makefile, to compile tests with the standard library using NAMESPACE=std
or with ft_containers using NAMESPACE=ft
.
make run
#include <iostream>
#include "vector.hpp"
int main() {
// Declare a vector of int
ft::vector<int> v;
// Reserve memory for 12 elements
v.reserve(12);
// Add 10 elements with value from 0 to 9
for (int i = 0; i < 10; ++i)
v.push_back(i);
// Insert 2 elements with value 42 between the 5th and 6th element
v.insert(v.begin() + 5, 2, 42);
// Print all elements
for (ft::vector<int>::iterator it = v.begin(); it != v.end(); ++it)
std::cout << ' ' << *it;
std::cout << std::endl;
}
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.