diff --git a/correction.png b/correction.png new file mode 100644 index 0000000..d602d63 Binary files /dev/null and b/correction.png differ diff --git a/templates/map.tpp b/templates/map.tpp index ada0436..e0e088c 100644 --- a/templates/map.tpp +++ b/templates/map.tpp @@ -152,9 +152,9 @@ MP_TPL pair MP:: if (value.first == n->value.first) return ft::make_pair(iterator(n, _sentinel), false); n = next; - if (value.first < n->value.first) + if (_comp(value.first, n->value.first)) next = n->left; - else if (value.first > n->value.first) + else if (_comp(n->value.first, value.first)) next = n->right; } @@ -168,9 +168,9 @@ MP_TPL pair MP:: } else { - if (value.first < n->value.first) + if (_comp(value.first, n->value.first)) n->left = next; - else if (value.first > n->value.first) + else if (_comp(n->value.first, value.first)) n->right = next; } next->up = n; diff --git a/tests/tests_vector.cpp b/tests/tests_vector.cpp index 72ed431..08e5950 100644 --- a/tests/tests_vector.cpp +++ b/tests/tests_vector.cpp @@ -639,8 +639,19 @@ TEST_V(tests_vector_swap) ft::vector foo (3,VAL(100)); // three ints with a value of 100 ft::vector bar (5,VAL(200)); // five ints with a value of 200 + typename ft::vector::iterator it1 = foo.begin(); + typename ft::vector::iterator it2 = bar.begin(); + + std::cout << "it1:" << *it1 << " - it2:" << *it2 << "\n"; + std::cout << "foo.begin():" << *(foo.begin()) << " - bar.begin():" << *(bar.begin()) << "\n"; + foo.swap(bar); + std::cout << "swap\n"; + + std::cout << "it1:" << *it1 << " - it2:" << *it2 << "\n"; + std::cout << "foo.begin():" << *(foo.begin()) << " - bar.begin():" << *(bar.begin()) << "\n"; + PRINT(foo) PRINT(bar)