diff options
Diffstat (limited to 'vector.hpp')
-rw-r--r-- | vector.hpp | 58 |
1 files changed, 51 insertions, 7 deletions
@@ -288,23 +288,67 @@ namespace ft { }; template<class T, class Alloc> void swap(vector<T,Alloc>& lhs, - vector<T,Alloc>& rhs); + vector<T,Alloc>& rhs) + { + lhs.swap(rhs); + } + template<class T, class Alloc> bool operator==(const vector<T,Alloc>& lhs, - const vector<T,Alloc>& rhs); + const vector<T,Alloc>& rhs) + { + if (lhs.size() != rhs.size()) + return false; + for (typename vector<T,Alloc>::size_type i = 0; i < lhs.size(); i++) + if (lhs[i] != rhs[i]) + return false; + return true; + } + template<class T, class Alloc> bool operator!=(const vector<T,Alloc>& lhs, - const vector<T,Alloc>& rhs); + const vector<T,Alloc>& rhs) + { + return !(lhs == rhs); + } + template<class T, class Alloc> bool operator<(const vector<T,Alloc>& lhs, - const vector<T,Alloc>& rhs); + const vector<T,Alloc>& rhs) + { + const typename vector<T,Alloc>::size_type end + (lhs.size() < rhs.size() ? lhs.size() : rhs.size()); + for (typename vector<T,Alloc>::size_type i = 0; i < end; i++) { + if (lhs[i] < rhs[i]) + return true; + } + return lhs.size() < rhs.size(); + } + template<class T, class Alloc> bool operator<=(const vector<T,Alloc>& lhs, - const vector<T,Alloc>& rhs); + const vector<T,Alloc>& rhs) + { + return !(lhs > rhs); + } + template<class T, class Alloc> bool operator>(const vector<T,Alloc>& lhs, - const vector<T,Alloc>& rhs); + const vector<T,Alloc>& rhs) + { + const typename vector<T,Alloc>::size_type end + (lhs.size() < rhs.size() ? lhs.size() : rhs.size()); + for (typename vector<T,Alloc>::size_type i = 0; i < end; i++) { + if (lhs[i] > rhs[i]) + return true; + } + return lhs.size() > rhs.size(); + } + template<class T, class Alloc> bool operator>=(const vector<T,Alloc>& lhs, - const vector<T,Alloc>& rhs); + const vector<T,Alloc>& rhs) + { + return !(lhs < rhs); + } } |