vector bi_it

This commit is contained in:
kinou-p 2022-11-29 15:52:37 +01:00
parent f976f2194d
commit b026bc4ba3

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/12 19:46:32 by apommier #+# #+# */ /* Created: 2022/10/12 19:46:32 by apommier #+# #+# */
/* Updated: 2022/11/29 14:05:18 by apommier ### ########.fr */ /* Updated: 2022/11/29 15:46:33 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -20,6 +20,7 @@
# include "./iterators/reverse_iterator.hpp" # include "./iterators/reverse_iterator.hpp"
# include <cstddef> # include <cstddef>
# include <limits>
# include <memory> # include <memory>
# include <stdexcept> # include <stdexcept>
@ -323,15 +324,22 @@ class vector
//--------Modifiers-------- //--------Modifiers--------
//------------------------- //-------------------------
template <class InputIterator> template <class _InputIterator>
void assign (InputIterator first, InputIterator last, typename ft::enable_if<!ft::is_integral<InputIterator>::value, InputIterator>::type* = 0) void assign(typename ft::enable_if<!std::numeric_limits<_InputIterator>::is_integer, _InputIterator>::type first, _InputIterator last)
{ {
size_type diff = 0;
for (_InputIterator tmp = first; tmp != last; tmp++)
diff++;
size_type i = 0;
if (_capacity < diff)
i = 1;
this->clear(); this->clear();
while (first < last) if (i)
{ resize(diff);
push_back(*first); for (size_type tmp = 0; tmp != diff; tmp++)
first++; _alloc.construct(_tab + tmp, *first++);
} _size = diff;
} }
void assign (size_type n, const value_type& val) //fill void assign (size_type n, const value_type& val) //fill