From cc18f0202f683cb0d5a850ff5e220485de01c20e Mon Sep 17 00:00:00 2001 From: Mateusz Jakub Fila Date: Wed, 12 Jun 2024 09:48:51 +0200 Subject: [PATCH] clarify lack of operator-> for std::counted_iterator adapting collection iterators --- doc/collections_as_container.md | 4 ++-- tests/unittests/std_interoperability.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/collections_as_container.md b/doc/collections_as_container.md index 338fb24aa..758b77b36 100644 --- a/doc/collections_as_container.md +++ b/doc/collections_as_container.md @@ -167,8 +167,8 @@ In addition to the *LegacyForwardIterator* the C++ standard specifies also the * | `std::front_insert_iterator` | ❌ no | `push_front` not defined | | `std::insert_iterator` | ❌ no | `insert` not defined | | `std::const_iterator` (C++23) | ❌ no | C++23 not supported yet | -| `std::move_iterator` | ✔️ yes | Limited usefulness since dereference returns `reference` not rvalue (`&&`) | -| `std::counted_iterator` | ✔️ yes | | +| `std::move_iterator` | ✔️ yes | Limited usefulness since dereference returns `reference` type not rvalue reference (`&&`) | +| `std::counted_iterator` | ✔️ yes | `operator->` not defined as it requires `std::contiguous_iterator` | ## Collection and standard algorithms diff --git a/tests/unittests/std_interoperability.cpp b/tests/unittests/std_interoperability.cpp index 2a72952ea..cd0a5e64c 100644 --- a/tests/unittests/std_interoperability.cpp +++ b/tests/unittests/std_interoperability.cpp @@ -1117,6 +1117,11 @@ TEST_CASE("Collection and std iterator adaptors", "[collection][container][adapt REQUIRE(counted != std::default_sentinel); REQUIRE(counted.count() == 1); REQUIRE((*counted).cellID() == 42); + DOCUMENTED_STATIC_FAILURE(std::contiguous_iterator); // counted-> requires std::contiguous_iterator + // REQUIRE(counted->cellID() == 42); + DOCUMENTED_STATIC_FAILURE(traits::has_member_of_pointer_v); // can't base()->() because + // base() returns const object + // REQUIRE(counted.base()->cellID() == 42); REQUIRE(++counted == std::default_sentinel); } // const_iterator @@ -1128,6 +1133,11 @@ TEST_CASE("Collection and std iterator adaptors", "[collection][container][adapt REQUIRE(counted != std::default_sentinel); REQUIRE(counted.count() == 1); REQUIRE((*counted).cellID() == 42); + DOCUMENTED_STATIC_FAILURE(std::contiguous_iterator); // counted-> requires std::contiguous_iterator + // REQUIRE(counted->cellID() == 42) + DOCUMENTED_STATIC_FAILURE(traits::has_member_of_pointer_v); // can't base()->() because + // base() returns const object + // REQUIRE(counted.base()->cellID() == 42); REQUIRE(++counted == std::default_sentinel); } }