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