1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // bool operator==(array<T, N> const&, array<T, N> const&);
12 // bool operator!=(array<T, N> const&, array<T, N> const&);
13 // bool operator<(array<T, N> const&, array<T, N> const&);
14 // bool operator<=(array<T, N> const&, array<T, N> const&);
15 // bool operator>(array<T, N> const&, array<T, N> const&);
16 // bool operator>=(array<T, N> const&, array<T, N> const&);
23 #include "test_macros.h"
25 // std::array is explicitly allowed to be initialized with A a = { init-list };.
26 // Disable the missing braces warning for this reason.
27 #include "disable_missing_braces_warning.h"
29 template <class Array
>
30 void test_compare(const Array
& LHS
, const Array
& RHS
) {
31 typedef std::vector
<typename
Array::value_type
> Vector
;
32 const Vector
LHSV(LHS
.begin(), LHS
.end());
33 const Vector
RHSV(RHS
.begin(), RHS
.end());
34 assert((LHS
== RHS
) == (LHSV
== RHSV
));
35 assert((LHS
!= RHS
) == (LHSV
!= RHSV
));
36 assert((LHS
< RHS
) == (LHSV
< RHSV
));
37 assert((LHS
<= RHS
) == (LHSV
<= RHSV
));
38 assert((LHS
> RHS
) == (LHSV
> RHSV
));
39 assert((LHS
>= RHS
) == (LHSV
>= RHSV
));
42 template <int Dummy
> struct NoCompare
{};
47 typedef NoCompare
<0> T
;
48 typedef std::array
<T
, 3> C
;
50 // expected-error@algorithm:* 2 {{invalid operands to binary expression}}
51 TEST_IGNORE_NODISCARD (c1
== c1
);
52 TEST_IGNORE_NODISCARD (c1
< c1
);
55 typedef NoCompare
<1> T
;
56 typedef std::array
<T
, 3> C
;
58 // expected-error@algorithm:* 2 {{invalid operands to binary expression}}
59 TEST_IGNORE_NODISCARD (c1
!= c1
);
60 TEST_IGNORE_NODISCARD (c1
> c1
);
63 typedef NoCompare
<2> T
;
64 typedef std::array
<T
, 0> C
;
66 // expected-error@algorithm:* 2 {{invalid operands to binary expression}}
67 TEST_IGNORE_NODISCARD (c1
== c1
);
68 TEST_IGNORE_NODISCARD (c1
< c1
);