File tree 1 file changed +12
-12
lines changed
libcxx/test/std/algorithms/alg.modifying.operations/alg.swap
1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change 18
18
#include < cassert>
19
19
#include < memory>
20
20
#include < utility>
21
+ #include < __type_traits/is_constant_evaluated.h>
21
22
22
23
#include " test_macros.h"
23
24
#include " test_iterators.h"
@@ -67,12 +68,6 @@ struct TestUniquePtr {
67
68
}
68
69
};
69
70
};
70
-
71
- // This test is constexpr only since C++23 because constexpr std::unique_ptr is only available since C++23
72
- TEST_CONSTEXPR_CXX23 bool test_unique_ptr () {
73
- types::for_each (types::forward_iterator_list<std::unique_ptr<int >*>(), TestUniquePtr ());
74
- return true ;
75
- }
76
71
#endif
77
72
78
73
TEST_CONSTEXPR_CXX20 bool test_simple_cases () {
@@ -104,20 +99,25 @@ TEST_CONSTEXPR_CXX20 bool test_simple_cases() {
104
99
TEST_CONSTEXPR_CXX20 bool test () {
105
100
test_simple_cases ();
106
101
types::for_each (types::forward_iterator_list<int *>(), TestPtr ());
102
+
103
+ if (std::__libcpp_is_constant_evaluated ()) {
104
+ #if TEST_STD_VER >= 23
105
+ types::for_each (types::forward_iterator_list<std::unique_ptr<int >*>(), TestUniquePtr ());
106
+ #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
+
107
113
return true ;
108
114
}
109
115
110
116
int main (int , char **) {
111
117
test ();
112
- #if TEST_STD_VER >= 11
113
- test_unique_ptr ();
114
- #endif
115
118
#if TEST_STD_VER >= 20
116
119
static_assert (test ());
117
120
#endif
118
- #if TEST_STD_VER >= 23
119
- static_assert (test_unique_ptr ());
120
- #endif
121
121
122
122
return 0 ;
123
123
}
You can’t perform that action at this time.
0 commit comments