1*700637cbSDimitry Andric //===----------------------------------------------------------------------===// 2*700637cbSDimitry Andric // 3*700637cbSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*700637cbSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*700637cbSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*700637cbSDimitry Andric // 7*700637cbSDimitry Andric //===----------------------------------------------------------------------===// 8*700637cbSDimitry Andric 9*700637cbSDimitry Andric #ifndef _LIBCPP___VECTOR_COMPARISON_H 10*700637cbSDimitry Andric #define _LIBCPP___VECTOR_COMPARISON_H 11*700637cbSDimitry Andric 12*700637cbSDimitry Andric #include <__algorithm/equal.h> 13*700637cbSDimitry Andric #include <__algorithm/lexicographical_compare.h> 14*700637cbSDimitry Andric #include <__algorithm/lexicographical_compare_three_way.h> 15*700637cbSDimitry Andric #include <__compare/synth_three_way.h> 16*700637cbSDimitry Andric #include <__config> 17*700637cbSDimitry Andric #include <__fwd/vector.h> 18*700637cbSDimitry Andric 19*700637cbSDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 20*700637cbSDimitry Andric # pragma GCC system_header 21*700637cbSDimitry Andric #endif 22*700637cbSDimitry Andric 23*700637cbSDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD 24*700637cbSDimitry Andric 25*700637cbSDimitry Andric template <class _Tp, class _Allocator> 26*700637cbSDimitry Andric _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI bool 27*700637cbSDimitry Andric operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { 28*700637cbSDimitry Andric const typename vector<_Tp, _Allocator>::size_type __sz = __x.size(); 29*700637cbSDimitry Andric return __sz == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); 30*700637cbSDimitry Andric } 31*700637cbSDimitry Andric 32*700637cbSDimitry Andric #if _LIBCPP_STD_VER <= 17 33*700637cbSDimitry Andric 34*700637cbSDimitry Andric template <class _Tp, class _Allocator> 35*700637cbSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { 36*700637cbSDimitry Andric return !(__x == __y); 37*700637cbSDimitry Andric } 38*700637cbSDimitry Andric 39*700637cbSDimitry Andric template <class _Tp, class _Allocator> 40*700637cbSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI bool operator<(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { 41*700637cbSDimitry Andric return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); 42*700637cbSDimitry Andric } 43*700637cbSDimitry Andric 44*700637cbSDimitry Andric template <class _Tp, class _Allocator> 45*700637cbSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI bool operator>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { 46*700637cbSDimitry Andric return __y < __x; 47*700637cbSDimitry Andric } 48*700637cbSDimitry Andric 49*700637cbSDimitry Andric template <class _Tp, class _Allocator> 50*700637cbSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { 51*700637cbSDimitry Andric return !(__x < __y); 52*700637cbSDimitry Andric } 53*700637cbSDimitry Andric 54*700637cbSDimitry Andric template <class _Tp, class _Allocator> 55*700637cbSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { 56*700637cbSDimitry Andric return !(__y < __x); 57*700637cbSDimitry Andric } 58*700637cbSDimitry Andric 59*700637cbSDimitry Andric #else // _LIBCPP_STD_VER <= 17 60*700637cbSDimitry Andric 61*700637cbSDimitry Andric template <class _Tp, class _Allocator> 62*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp> 63*700637cbSDimitry Andric operator<=>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { 64*700637cbSDimitry Andric return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); 65*700637cbSDimitry Andric } 66*700637cbSDimitry Andric 67*700637cbSDimitry Andric #endif // _LIBCPP_STD_VER <= 17 68*700637cbSDimitry Andric 69*700637cbSDimitry Andric _LIBCPP_END_NAMESPACE_STD 70*700637cbSDimitry Andric 71*700637cbSDimitry Andric #endif // _LIBCPP___VECTOR_COMPARISON_H 72