add namespace, make stl, and template allocator

This commit is contained in:
hugogogo
2022-06-03 14:49:22 +02:00
parent 6362a50ffa
commit aecd2caa1c
6 changed files with 262 additions and 197 deletions

View File

@@ -1,26 +1,48 @@
#ifndef FTVECTOR_HPP
# define FTVECTOR_HPP
#ifndef VECTOR_HPP
# define VECTOR_HPP
# include "colors.h"
# include <iostream>
# include <string>
# include <memory> // std::allocator
# include <memory> // std::allocator
# include <algorithm> // std::min
class ftvector {
namespace ft {
template <
class T,
class Allocator = std::allocator<T>
> class vector {
public:
typedef int value_type;
typedef std::allocator<int> allocator_type;
typedef std::size_t size_type;
typedef T value_type;
typedef Allocator allocator_type;
typedef std::size_t size_type;
typedef int * iterator;
typedef T * iterator;
ftvector();
ftvector( ftvector const & src );
~ftvector();
ftvector & operator=( ftvector const & rhs );
typedef typename allocator_type::reference reference;
/************
* copliens :
************/
// constructor -------------------------------
// explicit vector (const allocator_type& alloc = allocator_type());
// explicit vector (size_type n, const value_type& val = value_type(), const allocator_type& alloc = allocator_type());
// template <class InputIterator>
// vector (InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());
// vector (const vector& x);
// TMP
vector();
vector( vector const & src );
// TMP END
// destructor --------------------------------
~vector();
// operator= ---------------------------------
vector & operator=( vector const & rhs );
/*************
@@ -59,7 +81,7 @@ public:
* element access :
******************/
// operator[] --------------------------------
//reference operator[](size_type n);
reference operator[](size_type n);
//const_reference operator[](size_type n) const;
// at ----------------------------------------
//reference at(size_type n);
@@ -107,7 +129,11 @@ private:
};
//std::ostream & operator<<(std::ostream & o, ftvector const & rhs);
//std::ostream & operator<<(std::ostream & o, vector const & rhs);
}
# include "vector.tpp"
#endif