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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // constexpr common_iterator(S s);
15 #include <type_traits>
17 #include "test_iterators.h"
20 constexpr bool test() {
21 using Sent
= sentinel_wrapper
<It
>;
22 using CommonIt
= std::common_iterator
<It
, Sent
>;
25 Sent sent
= Sent(It(a
+1));
27 CommonIt lv
= CommonIt(sent
);
28 assert(lv
== CommonIt(sent
));
29 assert(lv
!= CommonIt(it
));
30 if (!std::is_constant_evaluated()) {
31 assert(lv
== std::next(CommonIt(it
)));
34 CommonIt rv
= CommonIt(std::move(sent
));
35 assert(rv
== CommonIt(sent
));
36 assert(rv
!= CommonIt(it
));
37 if (!std::is_constant_evaluated()) {
38 assert(rv
== std::next(CommonIt(it
)));
44 int main(int, char**) {
45 test
<cpp17_input_iterator
<int*>>();
46 test
<forward_iterator
<int*>>();
47 test
<bidirectional_iterator
<int*>>();
48 test
<random_access_iterator
<int*>>();
49 test
<contiguous_iterator
<int*>>();
53 static_assert(test
<cpp17_input_iterator
<int*>>());
54 static_assert(test
<forward_iterator
<int*>>());
55 static_assert(test
<bidirectional_iterator
<int*>>());
56 static_assert(test
<random_access_iterator
<int*>>());
57 static_assert(test
<contiguous_iterator
<int*>>());
58 static_assert(test
<int*>());
59 static_assert(test
<const int*>());