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
22static_assert(std::weakly_incrementable<int>);
23static_assert(std::weakly_incrementable<int*>);
24static_assert(std::weakly_incrementable<int**>);
25static_assert(!std::weakly_incrementable<int[]>);
26static_assert(!std::weakly_incrementable<int[10]>);
27static_assert(!std::weakly_incrementable<double>);
28static_assert(!std::weakly_incrementable<int&>);
29static_assert(!std::weakly_incrementable<int()>);
30static_assert(!std::weakly_incrementable<int (*)()>);
31static_assert(!std::weakly_incrementable<int (&)()>);
32static_assert(!std::weakly_incrementable<bool>);
33
34struct S {};
35static_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
46CHECK_POINTER_TO_MEMBER_FUNCTIONS(NO_QUALIFIER);
47CHECK_POINTER_TO_MEMBER_FUNCTIONS(const);
48CHECK_POINTER_TO_MEMBER_FUNCTIONS(volatile);
49CHECK_POINTER_TO_MEMBER_FUNCTIONS(const volatile);
50
51static_assert(std::weakly_incrementable<postfix_increment_returns_void>);
52static_assert(std::weakly_incrementable<postfix_increment_returns_copy>);
53static_assert(std::weakly_incrementable<has_integral_minus>);
54static_assert(std::weakly_incrementable<has_distinct_difference_type_and_minus>);
55static_assert(!std::weakly_incrementable<missing_difference_type>);
56static_assert(!std::weakly_incrementable<floating_difference_type>);
57static_assert(!std::weakly_incrementable<non_const_minus>);
58static_assert(!std::weakly_incrementable<non_integral_minus>);
59static_assert(!std::weakly_incrementable<bad_difference_type_good_minus>);
60static_assert(!std::weakly_incrementable<not_movable>);
61static_assert(!std::weakly_incrementable<preinc_not_declared>);
62static_assert(!std::weakly_incrementable<postinc_not_declared>);
63static_assert(std::weakly_incrementable<not_default_initializable>);
64static_assert(std::weakly_incrementable<incrementable_with_difference_type>);
65static_assert(std::weakly_incrementable<incrementable_without_difference_type>);
66static_assert(std::weakly_incrementable<difference_type_and_void_minus>);
67static_assert(std::weakly_incrementable<noncopyable_with_difference_type>);
68static_assert(std::weakly_incrementable<noncopyable_without_difference_type>);
69static_assert(std::weakly_incrementable<noncopyable_with_difference_type_and_minus>);
70

source code of libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.winc/weakly_incrementable.compile.pass.cpp