1 | //===----------------------------------------------------------------------===// |
2 | // |
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 |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // UNSUPPORTED: c++03, c++11, c++14, c++17 |
10 | |
11 | // template<class In> |
12 | // concept std::weakly_incrementable; |
13 | |
14 | #include <iterator> |
15 | |
16 | #include <concepts> |
17 | #include <memory> |
18 | #include <optional> |
19 | |
20 | #include "../incrementable.h" |
21 | |
22 | static_assert(std::weakly_incrementable<int>); |
23 | static_assert(std::weakly_incrementable<int*>); |
24 | static_assert(std::weakly_incrementable<int**>); |
25 | static_assert(!std::weakly_incrementable<int[]>); |
26 | static_assert(!std::weakly_incrementable<int[10]>); |
27 | static_assert(!std::weakly_incrementable<double>); |
28 | static_assert(!std::weakly_incrementable<int&>); |
29 | static_assert(!std::weakly_incrementable<int()>); |
30 | static_assert(!std::weakly_incrementable<int (*)()>); |
31 | static_assert(!std::weakly_incrementable<int (&)()>); |
32 | static_assert(!std::weakly_incrementable<bool>); |
33 | |
34 | struct S {}; |
35 | static_assert(!std::weakly_incrementable<int S::*>); |
36 | |
37 | #define CHECK_POINTER_TO_MEMBER_FUNCTIONS(qualifier) \ |
38 | static_assert(!std::weakly_incrementable<int (S::*)() qualifier>); \ |
39 | static_assert(!std::weakly_incrementable<int (S::*)() qualifier noexcept>); \ |
40 | static_assert(!std::weakly_incrementable<int (S::*)() qualifier&>); \ |
41 | static_assert(!std::weakly_incrementable<int (S::*)() qualifier & noexcept>); \ |
42 | static_assert(!std::weakly_incrementable<int (S::*)() qualifier&&>); \ |
43 | static_assert(!std::weakly_incrementable < int (S::*)() qualifier&& noexcept >); |
44 | |
45 | #define NO_QUALIFIER |
46 | CHECK_POINTER_TO_MEMBER_FUNCTIONS(NO_QUALIFIER); |
47 | CHECK_POINTER_TO_MEMBER_FUNCTIONS(const); |
48 | CHECK_POINTER_TO_MEMBER_FUNCTIONS(volatile); |
49 | CHECK_POINTER_TO_MEMBER_FUNCTIONS(const volatile); |
50 | |
51 | static_assert(std::weakly_incrementable<postfix_increment_returns_void>); |
52 | static_assert(std::weakly_incrementable<postfix_increment_returns_copy>); |
53 | static_assert(std::weakly_incrementable<has_integral_minus>); |
54 | static_assert(std::weakly_incrementable<has_distinct_difference_type_and_minus>); |
55 | static_assert(!std::weakly_incrementable<missing_difference_type>); |
56 | static_assert(!std::weakly_incrementable<floating_difference_type>); |
57 | static_assert(!std::weakly_incrementable<non_const_minus>); |
58 | static_assert(!std::weakly_incrementable<non_integral_minus>); |
59 | static_assert(!std::weakly_incrementable<bad_difference_type_good_minus>); |
60 | static_assert(!std::weakly_incrementable<not_movable>); |
61 | static_assert(!std::weakly_incrementable<preinc_not_declared>); |
62 | static_assert(!std::weakly_incrementable<postinc_not_declared>); |
63 | static_assert(std::weakly_incrementable<not_default_initializable>); |
64 | static_assert(std::weakly_incrementable<incrementable_with_difference_type>); |
65 | static_assert(std::weakly_incrementable<incrementable_without_difference_type>); |
66 | static_assert(std::weakly_incrementable<difference_type_and_void_minus>); |
67 | static_assert(std::weakly_incrementable<noncopyable_with_difference_type>); |
68 | static_assert(std::weakly_incrementable<noncopyable_without_difference_type>); |
69 | static_assert(std::weakly_incrementable<noncopyable_with_difference_type_and_minus>); |
70 | |