Skip to content

Commit

Permalink
clarify lack of operator-> for std::counted_iterator adapting collect…
Browse files Browse the repository at this point in the history
…ion iterators
  • Loading branch information
m-fila committed Jun 12, 2024
1 parent 38a014f commit cc18f02
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/collections_as_container.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tests/unittests/std_interoperability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<iterator>); // counted-> requires std::contiguous_iterator
// REQUIRE(counted->cellID() == 42);
DOCUMENTED_STATIC_FAILURE(traits::has_member_of_pointer_v<const iterator>); // can't base()->() because
// base() returns const object
// REQUIRE(counted.base()->cellID() == 42);
REQUIRE(++counted == std::default_sentinel);
}
// const_iterator
Expand All @@ -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<iterator>); // counted-> requires std::contiguous_iterator
// REQUIRE(counted->cellID() == 42)
DOCUMENTED_STATIC_FAILURE(traits::has_member_of_pointer_v<const const_iterator>); // can't base()->() because
// base() returns const object
// REQUIRE(counted.base()->cellID() == 42);
REQUIRE(++counted == std::default_sentinel);
}
}
Expand Down

0 comments on commit cc18f02

Please sign in to comment.