diff --git a/libcxx/include/__iterator/concepts.h b/libcxx/include/__iterator/concepts.h index a65413180027..95f68914836b 100644 --- a/libcxx/include/__iterator/concepts.h +++ b/libcxx/include/__iterator/concepts.h @@ -167,7 +167,6 @@ concept contiguous_iterator = { _VSTD::to_address(__i) } -> same_as>>; }; - template concept __has_arrow = input_iterator<_Ip> && (is_pointer_v<_Ip> || requires(_Ip __i) { __i.operator->(); }); @@ -236,6 +235,19 @@ template requires (indirectly_readable<_Its> && ...) && invocable<_Fp, iter_reference_t<_Its>...> using indirect_result_t = invoke_result_t<_Fp, iter_reference_t<_Its>...>; +template +concept indirectly_movable = + indirectly_readable<_In> && + indirectly_writable<_Out, iter_rvalue_reference_t<_In>>; + +template +concept indirectly_movable_storable = + indirectly_movable<_In, _Out> && + indirectly_writable<_Out, iter_value_t<_In>> && + movable> && + constructible_from, iter_rvalue_reference_t<_In>> && + assignable_from&, iter_rvalue_reference_t<_In>>; + // clang-format on #endif // !defined(_LIBCPP_HAS_NO_RANGES) diff --git a/libcxx/include/iterator b/libcxx/include/iterator index 08faf4d931af..929cc164384e 100644 --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -125,6 +125,13 @@ template Proj> template Proj> struct incrementable_traits>; // since C++20 +// [alg.req.ind.move], concept indirectly_movable +template + concept indirectly_movable = see below; // since C++20 + +template + concept indirectly_movable_storable = see below; // since C++20 + template struct iterator // deprecated in C++17 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 index c74dcfa5a747..43fa91d8a451 100644 --- 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 @@ -33,6 +33,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert( std::indirectly_movable*>); +static_assert(!std::indirectly_movable_storable*>); static_assert(std::bidirectional_iterator); static_assert(!std::random_access_iterator); 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 index 21a612ac350e..539d01e002ef 100644 --- 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 @@ -33,6 +33,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert( std::indirectly_movable*>); +static_assert(!std::indirectly_movable_storable*>); static_assert(std::bidirectional_iterator); static_assert(!std::random_access_iterator); 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 index 6c89f2df7d7f..0b44c3ed4069 100644 --- 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 @@ -33,6 +33,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert(std::indirectly_movable); +static_assert(std::indirectly_movable_storable); static_assert(std::bidirectional_iterator); static_assert(!std::random_access_iterator); 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 index f33771f20926..76b42fef3394 100644 --- 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 @@ -33,6 +33,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert(std::indirectly_movable); +static_assert(std::indirectly_movable_storable); static_assert(std::bidirectional_iterator); static_assert(!std::random_access_iterator); 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 index 0987835fcda0..29a0f3ade42a 100644 --- 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 @@ -31,6 +31,14 @@ static_assert(std::sized_sentinel_for); static_assert(std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); static_assert(std::contiguous_iterator); static_assert(!std::indirectly_writable); @@ -42,3 +50,11 @@ static_assert(std::sized_sentinel_for); static_assert(std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); 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 index 248e34b51572..1b1bf60272f2 100644 --- 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 @@ -33,6 +33,14 @@ static_assert(std::sized_sentinel_for); static_assert(std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); static_assert(std::random_access_iterator); static_assert(!std::contiguous_iterator); @@ -45,3 +53,11 @@ static_assert(std::sized_sentinel_for); static_assert(std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); 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 index 6a3edcbd98b5..8caa26e1fde3 100644 --- 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 @@ -27,6 +27,10 @@ static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); static_assert(std::forward_iterator); static_assert(!std::bidirectional_iterator); @@ -35,3 +39,7 @@ static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); 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 index fe3e1486ecfd..2a4ffe57d900 100644 --- 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 @@ -33,6 +33,14 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); static_assert(std::bidirectional_iterator); static_assert(!std::random_access_iterator); @@ -45,3 +53,11 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); 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 index 7f5f87b2f818..037383af0308 100644 --- 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,30 +22,32 @@ using reverse_iterator = std::vector::reverse_iterator; using const_reverse_iterator = std::vector::const_reverse_iterator; using value_type = bool; -static_assert(std::random_access_iterator); -static_assert(std::random_access_iterator); +static_assert( std::random_access_iterator); +static_assert( std::random_access_iterator); static_assert(!std::contiguous_iterator); static_assert(!std::contiguous_iterator); static_assert(!std::indirectly_writable); -static_assert(std::sentinel_for); -static_assert(std::sentinel_for); +static_assert( std::sentinel_for); +static_assert( std::sentinel_for); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); -static_assert(std::sized_sentinel_for); -static_assert(std::sized_sentinel_for); +static_assert( std::sized_sentinel_for); +static_assert( std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert(std::indirectly_movable); +static_assert(std::indirectly_movable_storable); -static_assert(std::random_access_iterator); -static_assert(std::random_access_iterator); +static_assert( std::random_access_iterator); +static_assert( std::random_access_iterator); static_assert(!std::contiguous_iterator); static_assert(!std::contiguous_iterator); static_assert(!std::indirectly_writable); -static_assert(std::sentinel_for); -static_assert(std::sentinel_for); +static_assert( std::sentinel_for); +static_assert( std::sentinel_for); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); -static_assert(std::sized_sentinel_for); -static_assert(std::sized_sentinel_for); +static_assert( std::sized_sentinel_for); +static_assert( std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); 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 index e1160dc5f7df..3af726723176 100644 --- 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,28 +22,44 @@ using reverse_iterator = std::vector::reverse_iterator; using const_reverse_iterator = std::vector::const_reverse_iterator; using value_type = int; -static_assert(std::contiguous_iterator); -static_assert(std::random_access_iterator); +static_assert( std::contiguous_iterator); +static_assert( std::random_access_iterator); static_assert(!std::contiguous_iterator); -static_assert(std::indirectly_writable); -static_assert(std::sentinel_for); -static_assert(std::sentinel_for); +static_assert( std::indirectly_writable); +static_assert( std::sentinel_for); +static_assert( std::sentinel_for); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); -static_assert(std::sized_sentinel_for); -static_assert(std::sized_sentinel_for); +static_assert( std::sized_sentinel_for); +static_assert( std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); -static_assert(std::contiguous_iterator); -static_assert(std::random_access_iterator); +static_assert( std::contiguous_iterator); +static_assert( std::random_access_iterator); static_assert(!std::contiguous_iterator); static_assert(!std::indirectly_writable); -static_assert(std::sentinel_for); -static_assert(std::sentinel_for); +static_assert( std::sentinel_for); +static_assert( std::sentinel_for); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); -static_assert(std::sized_sentinel_for); -static_assert(std::sized_sentinel_for); +static_assert( std::sized_sentinel_for); +static_assert( std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable_storable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); 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 index 8f23959c1181..7f8403029f2d 100644 --- 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 @@ -33,6 +33,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert(std::indirectly_movable*>); +static_assert(!std::indirectly_movable_storable*>); static_assert(std::forward_iterator); static_assert(!std::bidirectional_iterator); @@ -57,6 +59,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert(std::indirectly_movable*>); +static_assert(!std::indirectly_movable_storable*>); static_assert(std::forward_iterator); static_assert(!std::bidirectional_iterator); 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 index 1b73f1785b2f..b5afdc11a2f7 100644 --- 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 @@ -33,6 +33,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert(std::indirectly_movable*>); +static_assert(!std::indirectly_movable_storable*>); static_assert(std::forward_iterator); static_assert(!std::bidirectional_iterator); @@ -57,6 +59,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert(std::indirectly_movable*>); +static_assert(!std::indirectly_movable_storable*>); static_assert(std::forward_iterator); static_assert(!std::bidirectional_iterator); 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 index 25e25c4493fe..eb318ca19e95 100644 --- 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 @@ -33,6 +33,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert(std::indirectly_movable); +static_assert(std::indirectly_movable_storable); static_assert(std::forward_iterator); static_assert(!std::bidirectional_iterator); @@ -57,6 +59,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert(std::indirectly_movable); +static_assert(std::indirectly_movable_storable); static_assert(std::forward_iterator); static_assert(!std::bidirectional_iterator); 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 index 50426a2a4c37..db4d5c115989 100644 --- 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 @@ -33,6 +33,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert(std::indirectly_movable); +static_assert(std::indirectly_movable_storable); static_assert(std::forward_iterator); static_assert(!std::bidirectional_iterator); @@ -56,6 +58,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert(std::indirectly_movable); +static_assert(std::indirectly_movable_storable); static_assert(std::forward_iterator); static_assert(!std::bidirectional_iterator); 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 index 80022c298796..bbbddcd211e3 100644 --- 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 @@ -26,3 +26,5 @@ static_assert(std::sentinel_for); static_assert(!std::sentinel_for); static_assert(std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert(std::indirectly_movable); +static_assert(std::indirectly_movable_storable); 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 index 63ab32c0f031..1d3016ca9833 100644 --- 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 @@ -24,6 +24,8 @@ static_assert(!std::indirectly_writable); static_assert(!std::incrementable); static_assert(std::sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); static_assert(std::input_iterator); static_assert(!std::forward_iterator); @@ -31,3 +33,5 @@ static_assert(!std::indirectly_writable); static_assert(std::sentinel_for); static_assert(!std::sized_sentinel_for); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable_storable); diff --git a/libcxx/test/std/iterators/iterator.requirements/alg.req.ind.move/indirectly_movable.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/alg.req.ind.move/indirectly_movable.compile.pass.cpp new file mode 100644 index 000000000000..fb5b02df4dd3 --- /dev/null +++ b/libcxx/test/std/iterators/iterator.requirements/alg.req.ind.move/indirectly_movable.compile.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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_movable; + +#include + +#include "test_macros.h" + +struct IndirectlyMovableWithInt { + int& operator*() const; +}; + +struct Empty {}; + +struct MoveOnly { + MoveOnly(MoveOnly&&) = default; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly&&) = default; + MoveOnly& operator=(MoveOnly const&) = delete; + MoveOnly() = default; +}; + +template +struct PointerTo { + using value_type = T; + T& operator*() const; +}; + +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable); +static_assert( std::indirectly_movable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable); +static_assert(!std::indirectly_movable); +static_assert( std::indirectly_movable); +static_assert( std::indirectly_movable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable); +static_assert(!std::indirectly_movable); +static_assert( std::indirectly_movable, PointerTo>); +static_assert( std::indirectly_movable>); diff --git a/libcxx/test/std/iterators/iterator.requirements/alg.req.ind.move/indirectly_movable.subsumption.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/alg.req.ind.move/indirectly_movable.subsumption.compile.pass.cpp new file mode 100644 index 000000000000..b6c829d5c975 --- /dev/null +++ b/libcxx/test/std/iterators/iterator.requirements/alg.req.ind.move/indirectly_movable.subsumption.compile.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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_movable; + +#include + +#include + +template +constexpr bool indirectly_movable_subsumption() { + return false; +} + +template + requires std::indirectly_movable +constexpr bool indirectly_movable_subsumption() { + return true; +} + +static_assert(indirectly_movable_subsumption()); diff --git a/libcxx/test/std/iterators/iterator.requirements/alg.req.ind.move/indirectly_movable_storable.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/alg.req.ind.move/indirectly_movable_storable.compile.pass.cpp new file mode 100644 index 000000000000..16ab3de69aa3 --- /dev/null +++ b/libcxx/test/std/iterators/iterator.requirements/alg.req.ind.move/indirectly_movable_storable.compile.pass.cpp @@ -0,0 +1,143 @@ +//===----------------------------------------------------------------------===// +// +// 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_movable_storable; + +#include + +#include "test_macros.h" + +struct Empty {}; + +struct MoveOnlyConvertible; +struct AssignableToMoveOnly; + +struct MoveOnly { + MoveOnly(MoveOnly&&) = default; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly&&) = default; + MoveOnly& operator=(MoveOnly const&) = delete; + MoveOnly() = default; + + MoveOnly& operator=(MoveOnlyConvertible const&) = delete; + MoveOnly& operator=(AssignableToMoveOnly const&); +}; + +template +struct PointerTo { + using value_type = ValueType; + T& operator*() const; +}; + +// MoveOnlyConvertible is convertible to MoveOnly, but not assignable to it. This is +// implemented by explicitly deleting "operator=(MoveOnlyConvertible)" in MoveOnly. +struct MoveOnlyConvertible { + operator MoveOnly&() const; +}; + +// This type can be constructed with a MoveOnly and assigned to a MoveOnly, so it does +// model indirectly_movable_storable. +struct AssignableToMoveOnly { + AssignableToMoveOnly() = default; + AssignableToMoveOnly(const MoveOnly&); +}; + +struct DeletedMoveCtor { + DeletedMoveCtor(DeletedMoveCtor&&) = delete; + DeletedMoveCtor& operator=(DeletedMoveCtor&&) = default; +}; + +struct CommonType { }; + +struct NotConstructibleFromRefIn { + struct ValueType { + operator CommonType&() const; + }; + + struct ReferenceType { + operator CommonType&() const; + }; + + using value_type = ValueType; + ReferenceType& operator*() const; +}; + +template