18
18
#include < cassert>
19
19
#include < memory>
20
20
#include < utility>
21
- #include < __type_traits/is_constant_evaluated.h >
21
+ #include < type_traits >
22
22
23
23
#include " test_macros.h"
24
24
#include " test_iterators.h"
@@ -70,25 +70,30 @@ struct TestUniquePtr {
70
70
};
71
71
#endif
72
72
73
+ template <template <class > class Iter1 , template <class > class Iter2 >
73
74
TEST_CONSTEXPR_CXX20 bool test_simple_cases () {
74
75
{
75
76
std::array<int , 3 > a = {1 , 2 , 3 }, a0 = a;
76
77
std::array<int , 3 > b = {4 , 5 , 6 }, b0 = b;
77
- std::swap_ranges (a.begin (), a.end (), b.begin ());
78
+ std::swap_ranges (Iter1< int *>( a.begin ()), Iter1< int *>( a.end ()), Iter2< int *>( b.begin () ));
78
79
assert (a == b0);
79
80
assert (b == a0);
80
81
}
81
82
{
82
83
std::array<std::array<int , 2 >, 2 > a = {{{0 , 1 }, {2 , 3 }}}, a0 = a;
83
84
std::array<std::array<int , 2 >, 2 > b = {{{9 , 8 }, {7 , 6 }}}, b0 = b;
84
- std::swap_ranges (a.begin (), a.end (), b.begin ());
85
+ using It1 = Iter1<std::array<std::array<int , 2 >, 2 >::iterator>;
86
+ using It2 = Iter2<std::array<std::array<int , 2 >, 2 >::iterator>;
87
+ std::swap_ranges (It1 (a.begin ()), It1 (a.end ()), It2 (b.begin ()));
85
88
assert (a == b0);
86
89
assert (b == a0);
87
90
}
88
91
{
89
92
std::array<std::array<int , 3 >, 3 > a = {{{0 , 1 , 2 }, {3 , 4 , 5 }, {6 , 7 , 8 }}}, a0 = a;
90
93
std::array<std::array<int , 3 >, 3 > b = {{{9 , 8 , 7 }, {6 , 5 , 4 }, {3 , 2 , 1 }}}, b0 = b;
91
- std::swap_ranges (a.begin (), a.end (), b.begin ());
94
+ using It1 = Iter1<std::array<std::array<int , 3 >, 3 >::iterator>;
95
+ using It2 = Iter2<std::array<std::array<int , 3 >, 3 >::iterator>;
96
+ std::swap_ranges (It1 (a.begin ()), It1 (a.end ()), It2 (b.begin ()));
92
97
assert (a == b0);
93
98
assert (b == a0);
94
99
}
@@ -97,18 +102,27 @@ TEST_CONSTEXPR_CXX20 bool test_simple_cases() {
97
102
}
98
103
99
104
TEST_CONSTEXPR_CXX20 bool test () {
100
- test_simple_cases ();
105
+ test_simple_cases<forward_iterator, forward_iterator>();
106
+ test_simple_cases<forward_iterator, bidirectional_iterator>();
107
+ test_simple_cases<forward_iterator, random_access_iterator>();
108
+ test_simple_cases<bidirectional_iterator, forward_iterator>();
109
+ test_simple_cases<bidirectional_iterator, bidirectional_iterator>();
110
+ test_simple_cases<bidirectional_iterator, random_access_iterator>();
111
+ test_simple_cases<random_access_iterator, random_access_iterator>();
112
+ #if TEST_STD_VER >= 20
113
+ test_simple_cases<std::type_identity_t , std::type_identity_t >();
114
+ #endif
115
+
101
116
types::for_each (types::forward_iterator_list<int *>(), TestPtr ());
102
117
103
- if (std::__libcpp_is_constant_evaluated ()) {
104
- #if TEST_STD_VER >= 23
118
+ #if TEST_STD_VER >= 11 && TEST_STD_VER <= 17
119
+ types::for_each (types::forward_iterator_list<std::unique_ptr<int >*>(), TestUniquePtr ());
120
+ #elif TEST_STD_VER == 20
121
+ if (!std::is_constant_evaluated ())
105
122
types::for_each (types::forward_iterator_list<std::unique_ptr<int >*>(), TestUniquePtr ());
123
+ #elif TEST_STD_VER >= 23
124
+ types::for_each (types::forward_iterator_list<std::unique_ptr<int >*>(), TestUniquePtr ());
106
125
#endif
107
- } else {
108
- #if TEST_STD_VER >= 11
109
- types::for_each (types::forward_iterator_list<std::unique_ptr<int >*>(), TestUniquePtr ());
110
- #endif
111
- }
112
126
113
127
return true ;
114
128
}
0 commit comments