Skip to content

Commit ad210cc

Browse files
committed
forward_linked_list uses std::default_sentinel as its end iterator.
1 parent 9756f5d commit ad210cc

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

source/containers/forward_linked_list.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,8 @@ struct [[clang::trivial_abi]] forward_linked_list trivially_relocatable_if_eligi
8585
constexpr auto before_begin() -> iterator {
8686
return iterator(std::addressof(m_sentinel));
8787
}
88-
constexpr auto end() const -> const_iterator {
89-
return const_iterator(nullptr);
90-
}
91-
constexpr auto end() -> iterator {
92-
return iterator(nullptr);
88+
static constexpr auto end() -> std::default_sentinel_t {
89+
return std::default_sentinel;
9390
}
9491

9592
constexpr auto mutable_iterator(const_iterator const it) & -> iterator {

source/containers/linked_list_helper.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ struct list_iterator {
8989
OPERATORS_ARROW_DEFINITIONS
9090

9191
friend auto operator==(list_iterator, list_iterator) -> bool = default;
92+
friend constexpr auto operator==(list_iterator const lhs, std::default_sentinel_t) -> bool requires(!has_previous<Links>) {
93+
return !lhs.m_links;
94+
}
9295

9396
friend constexpr auto operator+(list_iterator const it, bounded::constant_t<1>) {
9497
return list_iterator<Container, Links, T>(it.m_links->next);

0 commit comments

Comments
 (0)