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 // Test nested types and default template args:
13 // template <class T, class Allocator = allocator<T> >
16 // iterator, const_iterator
22 #include "test_macros.h"
23 #include "min_allocator.h"
28 typedef std::deque
<int> C
;
36 #if TEST_STD_VER >= 11
38 typedef std::deque
<int, min_allocator
<int>> C
;
54 # if TEST_STD_VER >= 20
56 // When the allocator does not have operator<=> then the iterator uses a
57 // fallback to provide operator<=>.
58 // Make sure to test with an allocator that does not have operator<=>.
59 static_assert(!std::three_way_comparable
<min_allocator
<int>, std::strong_ordering
>);
60 static_assert(std::three_way_comparable
<typename
C::iterator
, std::strong_ordering
>);
62 std::same_as
<std::strong_ordering
> decltype(auto) r1
= i
<=> j
;
63 assert(r1
== std::strong_ordering::equal
);
69 std::deque
<int>::iterator ii1
{}, ii2
{};
70 std::deque
<int>::iterator ii4
= ii1
;
71 std::deque
<int>::const_iterator cii
{};
72 assert ( ii1
== ii2
);
73 assert ( ii1
== ii4
);
75 assert (!(ii1
!= ii2
));
77 assert ( (ii1
== cii
));
78 assert ( (cii
== ii1
));
79 assert (!(ii1
!= cii
));
80 assert (!(cii
!= ii1
));
81 assert (!(ii1
< cii
));
82 assert (!(cii
< ii1
));
83 assert ( (ii1
<= cii
));
84 assert ( (cii
<= ii1
));
85 assert (!(ii1
> cii
));
86 assert (!(cii
> ii1
));
87 assert ( (ii1
>= cii
));
88 assert ( (cii
>= ii1
));
89 assert (cii
- ii1
== 0);
90 assert (ii1
- cii
== 0);
93 // assert ( ii1 != c.cbegin());
94 // assert ( cii != c.begin());
95 // assert ( cii != c.cend());
96 // assert ( ii1 != c.end());
98 # if TEST_STD_VER >= 20
100 std::same_as
<std::strong_ordering
> decltype(auto) r1
= ii1
<=> ii2
;
101 assert(r1
== std::strong_ordering::equal
);
103 std::same_as
<std::strong_ordering
> decltype(auto) r2
= cii
<=> ii2
;
104 assert(r2
== std::strong_ordering::equal
);
105 # endif // TEST_STD_VER > 20