diff --git a/libcxx/include/__iterator/concepts.h b/libcxx/include/__iterator/concepts.h --- a/libcxx/include/__iterator/concepts.h +++ b/libcxx/include/__iterator/concepts.h @@ -57,6 +57,30 @@ const_cast&&>(*_VSTD::forward<_Out>(__o)) = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving }; +// [iterator.concept.winc] +template +inline constexpr bool __is_signed_integer_like = signed_integral<_Tp>; + +template +concept weakly_incrementable = + default_initializable<_Ip> && + movable<_Ip> && + requires(_Ip __i) { + typename iter_difference_t<_Ip>; + requires __is_signed_integer_like >; + { ++__i } -> same_as<_Ip&>; // not required to be equality-preserving + __i++; // not required to be equality-preserving + }; + +// [iterator.concept.inc] +template +concept incrementable = + regular<_Ip> && + weakly_incrementable<_Ip> && + requires(_Ip __i) { + { __i++ } -> same_as<_Ip>; + }; + // clang-format on #endif // !defined(_LIBCPP_HAS_NO_RANGES) diff --git a/libcxx/include/iterator b/libcxx/include/iterator --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -52,6 +52,14 @@ template concept indirectly_writable = see below; // since C++20 +// [iterator.concept.winc], concept weakly_­incrementable +template + concept weakly_incrementable = see below; // since C++20 + +// [iterator.concept.inc], concept incrementable +template + concept incrementable = see below; // since C++20 + template struct iterator @@ -438,6 +446,7 @@ #include // Mandated by the Standard. #include #include +#include <__iterator/concepts.h> #include <__iterator/incrementable_traits.h> #include <__iterator/iter_move.h> #include <__iterator/iterator_traits.h> diff --git a/libcxx/test/std/containers/associative/map/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/associative/map/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/associative/map/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/associative/map/iterator_concept_conformance.compile.pass.cpp @@ -22,6 +22,8 @@ static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/containers/associative/multimap/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/associative/multimap/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/associative/multimap/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/iterator_concept_conformance.compile.pass.cpp @@ -22,6 +22,8 @@ static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/containers/associative/multiset/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/associative/multiset/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/associative/multiset/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/associative/multiset/iterator_concept_conformance.compile.pass.cpp @@ -22,6 +22,8 @@ static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/containers/associative/set/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/associative/set/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/associative/set/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/associative/set/iterator_concept_conformance.compile.pass.cpp @@ -22,6 +22,8 @@ static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/containers/sequences/array/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/array/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/array/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/array/iterator_concept_conformance.compile.pass.cpp @@ -21,6 +21,8 @@ static_assert(std::indirectly_readable); static_assert(std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/containers/sequences/deque/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/deque/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/deque/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/deque/iterator_concept_conformance.compile.pass.cpp @@ -22,6 +22,8 @@ static_assert(std::indirectly_readable); static_assert(std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/iterator_concept_conformance.compile.pass.cpp @@ -22,6 +22,8 @@ static_assert(std::indirectly_readable); static_assert(std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/containers/sequences/list/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/list/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/list/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/list/iterator_concept_conformance.compile.pass.cpp @@ -22,6 +22,8 @@ static_assert(std::indirectly_readable); static_assert(std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/containers/sequences/vector.bool/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/iterator_concept_conformance.compile.pass.cpp @@ -22,6 +22,8 @@ static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/containers/sequences/vector/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/iterator_concept_conformance.compile.pass.cpp @@ -22,6 +22,8 @@ static_assert(std::indirectly_readable); static_assert(std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/containers/unord/unord.map/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.map/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/unord/unord.map/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.map/iterator_concept_conformance.compile.pass.cpp @@ -24,12 +24,16 @@ static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/containers/unord/unord.multimap/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/unord/unord.multimap/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multimap/iterator_concept_conformance.compile.pass.cpp @@ -24,12 +24,16 @@ static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/containers/unord/unord.multiset/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/unord/unord.multiset/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multiset/iterator_concept_conformance.compile.pass.cpp @@ -24,12 +24,16 @@ static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/containers/unord/unord.set/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.set/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/unord/unord.set/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.set/iterator_concept_conformance.compile.pass.cpp @@ -24,12 +24,16 @@ static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/containers/views/span.iterators/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/views/span.iterators/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/views/span.iterators/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/views/span.iterators/iterator_concept_conformance.compile.pass.cpp @@ -21,3 +21,4 @@ static_assert(std::indirectly_readable); static_assert(std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/input.output/filesystems/class.directory_iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/iterator_concept_conformance.compile.pass.cpp @@ -18,7 +18,11 @@ static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::weakly_incrementable); +static_assert(!std::incrementable); static_assert(std::indirectly_readable); static_assert( !std::indirectly_writable); +static_assert(std::weakly_incrementable); +static_assert(!std::incrementable); diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/incrementable.h b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/incrementable.h new file mode 100644 --- /dev/null +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/incrementable.h @@ -0,0 +1,183 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +#ifndef LIBCPP_TEST_STD_ITERATORS_ITERATOR_REQUIREMENTS_ITERATOR_CONCEPTS_INCREMENTABLE_H +#define LIBCPP_TEST_STD_ITERATORS_ITERATOR_REQUIREMENTS_ITERATOR_CONCEPTS_INCREMENTABLE_H + +struct postfix_increment_returns_void { + using difference_type = int; + postfix_increment_returns_void& operator++(); + void operator++(int); +}; + +struct postfix_increment_returns_copy { + using difference_type = int; + postfix_increment_returns_copy& operator++(); + postfix_increment_returns_copy operator++(int); +}; + +struct has_integral_minus { + has_integral_minus& operator++(); + has_integral_minus operator++(int); + + long operator-(has_integral_minus) const; +}; + +struct has_distinct_difference_type_and_minus { + using difference_type = short; + + has_distinct_difference_type_and_minus& operator++(); + has_distinct_difference_type_and_minus operator++(int); + + long operator-(has_distinct_difference_type_and_minus) const; +}; + +struct missing_difference_type { + missing_difference_type& operator++(); + void operator++(int); +}; + +struct floating_difference_type { + using difference_type = float; + + floating_difference_type& operator++(); + void operator++(int); +}; + +struct non_const_minus { + non_const_minus& operator++(); + non_const_minus operator++(int); + + long operator-(non_const_minus); +}; + +struct non_integral_minus { + non_integral_minus& operator++(); + non_integral_minus operator++(int); + + void operator-(non_integral_minus); +}; + +struct bad_difference_type_good_minus { + using difference_type = float; + + bad_difference_type_good_minus& operator++(); + void operator++(int); + + int operator-(bad_difference_type_good_minus) const; +}; + +struct not_default_initializable { + using difference_type = int; + not_default_initializable() = delete; + + not_default_initializable& operator++(); + void operator++(int); +}; + +struct not_movable { + using difference_type = int; + + not_movable() = default; + not_movable(not_movable&&) = delete; + + not_movable& operator++(); + void operator++(int); +}; + +struct preinc_not_declared { + using difference_type = int; + + void operator++(int); +}; + +struct postinc_not_declared { + using difference_type = int; + + postinc_not_declared& operator++(); +}; + +struct incrementable_with_difference_type { + using difference_type = int; + + incrementable_with_difference_type& operator++(); + incrementable_with_difference_type operator++(int); + + bool operator==(incrementable_with_difference_type const&) const; +}; + +struct incrementable_without_difference_type { + incrementable_without_difference_type& operator++(); + incrementable_without_difference_type operator++(int); + + bool operator==(incrementable_without_difference_type const&) const; + + int operator-(incrementable_without_difference_type) const; +}; + +struct difference_type_and_void_minus { + using difference_type = int; + + difference_type_and_void_minus& operator++(); + difference_type_and_void_minus operator++(int); + + bool operator==(difference_type_and_void_minus const&) const; + + void operator-(difference_type_and_void_minus) const; +}; + +struct noncopyable_with_difference_type { + using difference_type = int; + + noncopyable_with_difference_type() = default; + noncopyable_with_difference_type(noncopyable_with_difference_type&&) = default; + noncopyable_with_difference_type(noncopyable_with_difference_type const&) = delete; + + noncopyable_with_difference_type& operator=(noncopyable_with_difference_type&&) = default; + noncopyable_with_difference_type& operator=(noncopyable_with_difference_type const&) = delete; + + noncopyable_with_difference_type& operator++(); + noncopyable_with_difference_type operator++(int); + + bool operator==(noncopyable_with_difference_type const&) const; +}; + +struct noncopyable_without_difference_type { + noncopyable_without_difference_type() = default; + noncopyable_without_difference_type(noncopyable_without_difference_type&&) = default; + noncopyable_without_difference_type(noncopyable_without_difference_type const&) = delete; + + noncopyable_without_difference_type& operator=(noncopyable_without_difference_type&&) = default; + noncopyable_without_difference_type& operator=(noncopyable_without_difference_type const&) = delete; + + noncopyable_without_difference_type& operator++(); + noncopyable_without_difference_type operator++(int); + + int operator-(noncopyable_without_difference_type const&) const; + + bool operator==(noncopyable_without_difference_type const&) const; +}; + +struct noncopyable_with_difference_type_and_minus { + using difference_type = int; + + noncopyable_with_difference_type_and_minus() = default; + noncopyable_with_difference_type_and_minus(noncopyable_with_difference_type_and_minus&&) = default; + noncopyable_with_difference_type_and_minus(noncopyable_with_difference_type_and_minus const&) = delete; + + noncopyable_with_difference_type_and_minus& operator=(noncopyable_with_difference_type_and_minus&&) = default; + noncopyable_with_difference_type_and_minus& operator=(noncopyable_with_difference_type_and_minus const&) = delete; + + noncopyable_with_difference_type_and_minus& operator++(); + noncopyable_with_difference_type_and_minus operator++(int); + + int operator-(noncopyable_with_difference_type_and_minus const&) const; + + bool operator==(noncopyable_with_difference_type_and_minus const&) const; +}; + +#endif // #define LIBCPP_TEST_STD_ITERATORS_ITERATOR_REQUIREMENTS_ITERATOR_CONCEPTS_INCREMENTABLE_H diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.inc/incrementable.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.inc/incrementable.compile.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.inc/incrementable.compile.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-no-concepts +// UNSUPPORTED: gcc-10 + +// template +// concept indirectly_readable; + +#include + +#include +#include +#include + +#include "../incrementable.h" + +static_assert(std::incrementable); +static_assert(std::incrementable); +static_assert(std::incrementable); + +static_assert(!std::incrementable); +static_assert(!std::incrementable); +static_assert(!std::incrementable); +static_assert(!std::incrementable); +static_assert(!std::incrementable); +static_assert(!std::incrementable); +static_assert(!std::incrementable); +static_assert(!std::incrementable); +static_assert(!std::incrementable); +static_assert(!std::incrementable); +static_assert(!std::incrementable); +static_assert(!std::incrementable); +static_assert(!std::incrementable); +static_assert(std::incrementable); +static_assert(std::incrementable); +static_assert(std::incrementable); +static_assert(!std::incrementable); +static_assert(!std::incrementable); +static_assert(!std::incrementable); diff --git a/libcxx/test/std/containers/views/span.iterators/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.inc/subsumption.compile.pass.cpp copy from libcxx/test/std/containers/views/span.iterators/iterator_concept_conformance.compile.pass.cpp copy to libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.inc/subsumption.compile.pass.cpp --- a/libcxx/test/std/containers/views/span.iterators/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.inc/subsumption.compile.pass.cpp @@ -10,14 +10,24 @@ // UNSUPPORTED: libcpp-no-concepts // UNSUPPORTED: gcc-10 -// iterator, reverse_iterator - -#include +// template +// concept incrementable; #include -using iterator = std::span::iterator; -using value_type = iterator::value_type; +#include + +// clang-format off +template +requires std::regular +[[nodiscard]] constexpr bool check_subsumption() { + return false; +} + +template +[[nodiscard]] constexpr bool check_subsumption() { + return true; +} +// clang-format on -static_assert(std::indirectly_readable); -static_assert(std::indirectly_writable); +static_assert(check_subsumption()); diff --git a/libcxx/test/std/containers/views/span.iterators/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.winc/subsumption.compile.pass.cpp copy from libcxx/test/std/containers/views/span.iterators/iterator_concept_conformance.compile.pass.cpp copy to libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.winc/subsumption.compile.pass.cpp --- a/libcxx/test/std/containers/views/span.iterators/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.winc/subsumption.compile.pass.cpp @@ -10,14 +10,24 @@ // UNSUPPORTED: libcpp-no-concepts // UNSUPPORTED: gcc-10 -// iterator, reverse_iterator - -#include +// template +// concept weakly_incrementable; #include -using iterator = std::span::iterator; -using value_type = iterator::value_type; +#include + +// clang-format off +template +requires std::movable +[[nodiscard]] constexpr bool check_subsumption() { + return false; +} + +template +[[nodiscard]] constexpr bool check_subsumption() { + return true; +} +// clang-format on -static_assert(std::indirectly_readable); -static_assert(std::indirectly_writable); +static_assert(check_subsumption()); diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.winc/weakly_incrementable.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.winc/weakly_incrementable.compile.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.winc/weakly_incrementable.compile.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-no-concepts +// UNSUPPORTED: gcc-10 + +// template +// concept std::weakly_incrementable; + +#include + +#include +#include +#include + +#include "../incrementable.h" + +static_assert(std::weakly_incrementable); +static_assert(std::weakly_incrementable); +static_assert(std::weakly_incrementable); +static_assert(!std::weakly_incrementable); +static_assert(!std::weakly_incrementable); +static_assert(!std::weakly_incrementable); +static_assert(!std::weakly_incrementable); +static_assert(!std::weakly_incrementable); +static_assert(!std::weakly_incrementable); +static_assert(!std::weakly_incrementable); + +struct S {}; +static_assert(!std::weakly_incrementable); + +#define CHECK_POINTER_TO_MEMBER_FUNCTIONS(qualifier) \ + static_assert(!std::weakly_incrementable); \ + static_assert(!std::weakly_incrementable); \ + static_assert(!std::weakly_incrementable); \ + static_assert(!std::weakly_incrementable); \ + static_assert(!std::weakly_incrementable); \ + static_assert(!std::weakly_incrementable < int (S::*)() qualifier&& noexcept >); + +#define NO_QUALIFIER +CHECK_POINTER_TO_MEMBER_FUNCTIONS(NO_QUALIFIER); +CHECK_POINTER_TO_MEMBER_FUNCTIONS(const); +CHECK_POINTER_TO_MEMBER_FUNCTIONS(volatile); +CHECK_POINTER_TO_MEMBER_FUNCTIONS(const volatile); + +static_assert(std::weakly_incrementable); +static_assert(std::weakly_incrementable); +static_assert(std::weakly_incrementable); +static_assert(std::weakly_incrementable); +static_assert(!std::weakly_incrementable); +static_assert(!std::weakly_incrementable); +static_assert(!std::weakly_incrementable); +static_assert(!std::weakly_incrementable); +static_assert(!std::weakly_incrementable); +static_assert(!std::weakly_incrementable); +static_assert(!std::weakly_incrementable); +static_assert(!std::weakly_incrementable); +static_assert(!std::weakly_incrementable); +static_assert(std::weakly_incrementable); +static_assert(std::weakly_incrementable); +static_assert(std::weakly_incrementable); +static_assert(std::weakly_incrementable); +static_assert(std::weakly_incrementable); +static_assert(std::weakly_incrementable); diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/iterator_concept_conformance.compile.pass.cpp @@ -19,3 +19,4 @@ using iterator = std::back_insert_iterator >; static_assert(!std::indirectly_readable); static_assert(std::indirectly_writable); +static_assert(!std::weakly_incrementable); diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/iterator_concept_conformance.compile.pass.cpp @@ -19,3 +19,4 @@ using iterator = std::front_insert_iterator >; static_assert(!std::indirectly_readable); static_assert(std::indirectly_writable); +static_assert(!std::weakly_incrementable); diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/iterator_concept_conformance.compile.pass.cpp @@ -19,3 +19,4 @@ using iterator = std::insert_iterator >; static_assert(!std::indirectly_readable); static_assert(std::indirectly_writable); +static_assert(!std::weakly_incrementable); diff --git a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/iterator_concept_conformance.compile.pass.cpp @@ -17,3 +17,4 @@ using iterator = std::move_iterator; static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/iterators/predef.iterators/reverse.iterators/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/predef.iterators/reverse.iterators/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/iterators/predef.iterators/reverse.iterators/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/reverse.iterators/iterator_concept_conformance.compile.pass.cpp @@ -17,3 +17,4 @@ using iterator = std::reverse_iterator; static_assert(std::indirectly_readable); static_assert(std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/iterators/stream.iterators/istream.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istream.iterator/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/iterators/stream.iterators/istream.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/stream.iterators/istream.iterator/iterator_concept_conformance.compile.pass.cpp @@ -19,3 +19,4 @@ using iterator = std::istream_iterator; static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/iterator_concept_conformance.compile.pass.cpp @@ -20,3 +20,5 @@ using iterator = std::istreambuf_iterator; static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::weakly_incrementable); +static_assert(!std::incrementable); diff --git a/libcxx/test/std/iterators/stream.iterators/ostream.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/iterators/stream.iterators/ostream.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/iterator_concept_conformance.compile.pass.cpp @@ -19,3 +19,4 @@ using iterator = std::ostream_iterator; static_assert(!std::indirectly_readable); static_assert(std::indirectly_writable); +static_assert(!std::weakly_incrementable); diff --git a/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/iterator_concept_conformance.compile.pass.cpp @@ -20,3 +20,4 @@ using iterator = std::ostreambuf_iterator; static_assert(!std::indirectly_readable); static_assert(std::indirectly_writable); +static_assert(!std::weakly_incrementable); diff --git a/libcxx/test/std/re/re.iter/re.regiter/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/re/re.iter/re.regiter/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/re/re.iter/re.regiter/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/re/re.iter/re.regiter/iterator_concept_conformance.compile.pass.cpp @@ -18,3 +18,4 @@ static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/re/re.iter/re.tokiter/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/re/re.iter/re.tokiter/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/re/re.iter/re.tokiter/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/re/re.iter/re.tokiter/iterator_concept_conformance.compile.pass.cpp @@ -18,3 +18,4 @@ static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/strings/basic.string/string.iterators/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.iterators/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.iterators/iterator_concept_conformance.compile.pass.cpp @@ -22,6 +22,8 @@ static_assert(std::indirectly_readable); static_assert(std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/strings/string.view/string.view.iterators/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/strings/string.view/string.view.iterators/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/strings/string.view/string.view.iterators/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.iterators/iterator_concept_conformance.compile.pass.cpp @@ -21,6 +21,8 @@ static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); +static_assert(std::incrementable); diff --git a/libcxx/test/std/utilities/memory/unique.ptr/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/utilities/memory/unique.ptr/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/utilities/memory/unique.ptr/iterator_concept_conformance.compile.pass.cpp @@ -18,6 +18,8 @@ static_assert(std::indirectly_readable >); static_assert(std::indirectly_writable, int>); +static_assert(!std::weakly_incrementable >); static_assert(!std::indirectly_readable >); static_assert(!std::indirectly_writable, void>); +static_assert(!std::weakly_incrementable >); diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/iterator_concept_conformance.compile.pass.cpp @@ -18,6 +18,8 @@ static_assert(std::indirectly_readable >); static_assert(std::indirectly_writable, int>); +static_assert(!std::weakly_incrementable >); static_assert(!std::indirectly_readable >); static_assert(!std::indirectly_writable, void>); +static_assert(!std::weakly_incrementable >); diff --git a/libcxx/test/std/utilities/optional/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/utilities/optional/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/utilities/optional/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/utilities/optional/iterator_concept_conformance.compile.pass.cpp @@ -18,3 +18,4 @@ static_assert(!std::indirectly_readable >); static_assert(!std::indirectly_writable, int>); +static_assert(!std::weakly_incrementable >);