Skip to content

Commit

Permalink
Fixes #311: adding operator-> to search_all iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
hanickadot committed Jul 20, 2024
1 parent acb2f4d commit 3dec174
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
9 changes: 7 additions & 2 deletions include/ctre/range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ template <typename Range, typename RE> struct multi_subject_range {
using iterator_category = std::forward_iterator_tag;
using pointer = void;
using reference = const value_type &;
using pointer = const value_type *;
using difference_type = int;

first_type first{};
Expand All @@ -67,10 +68,14 @@ template <typename Range, typename RE> struct multi_subject_range {
return {};
}

constexpr CTRE_FORCE_INLINE const value_type & operator*() const noexcept {
constexpr CTRE_FORCE_INLINE reference operator*() const noexcept {
return current_result;
}

constexpr CTRE_FORCE_INLINE pointer operator->() const noexcept {
return &current_result;
}

constexpr CTRE_FORCE_INLINE iterator & operator++() noexcept {
++first;
current_result = find_first();
Expand Down Expand Up @@ -117,7 +122,7 @@ template <typename Range, typename RE> struct multi_subject_range {
Range range{};

constexpr CTRE_FORCE_INLINE multi_subject_range() noexcept = default;
constexpr CTRE_FORCE_INLINE multi_subject_range(Range r) noexcept: range{r} { }
constexpr CTRE_FORCE_INLINE multi_subject_range(Range r) noexcept: range{r} { }

constexpr CTRE_FORCE_INLINE auto begin() const noexcept {
return iterator{range.begin(), range.end()};
Expand Down
9 changes: 7 additions & 2 deletions single-header/ctre-unicode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5343,6 +5343,7 @@ template <typename Range, typename RE> struct multi_subject_range {
using iterator_category = std::forward_iterator_tag;
using pointer = void;
using reference = const value_type &;
using pointer = const value_type *;
using difference_type = int;

first_type first{};
Expand All @@ -5360,10 +5361,14 @@ template <typename Range, typename RE> struct multi_subject_range {
return {};
}

constexpr CTRE_FORCE_INLINE const value_type & operator*() const noexcept {
constexpr CTRE_FORCE_INLINE reference operator*() const noexcept {
return current_result;
}

constexpr CTRE_FORCE_INLINE pointer operator->() const noexcept {
return &current_result;
}

constexpr CTRE_FORCE_INLINE iterator & operator++() noexcept {
++first;
current_result = find_first();
Expand Down Expand Up @@ -5410,7 +5415,7 @@ template <typename Range, typename RE> struct multi_subject_range {
Range range{};

constexpr CTRE_FORCE_INLINE multi_subject_range() noexcept = default;
constexpr CTRE_FORCE_INLINE multi_subject_range(Range r) noexcept: range{r} { }
constexpr CTRE_FORCE_INLINE multi_subject_range(Range r) noexcept: range{r} { }

constexpr CTRE_FORCE_INLINE auto begin() const noexcept {
return iterator{range.begin(), range.end()};
Expand Down
9 changes: 7 additions & 2 deletions single-header/ctre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5340,6 +5340,7 @@ template <typename Range, typename RE> struct multi_subject_range {
using iterator_category = std::forward_iterator_tag;
using pointer = void;
using reference = const value_type &;
using pointer = const value_type *;
using difference_type = int;

first_type first{};
Expand All @@ -5357,10 +5358,14 @@ template <typename Range, typename RE> struct multi_subject_range {
return {};
}

constexpr CTRE_FORCE_INLINE const value_type & operator*() const noexcept {
constexpr CTRE_FORCE_INLINE reference operator*() const noexcept {
return current_result;
}

constexpr CTRE_FORCE_INLINE pointer operator->() const noexcept {
return &current_result;
}

constexpr CTRE_FORCE_INLINE iterator & operator++() noexcept {
++first;
current_result = find_first();
Expand Down Expand Up @@ -5407,7 +5412,7 @@ template <typename Range, typename RE> struct multi_subject_range {
Range range{};

constexpr CTRE_FORCE_INLINE multi_subject_range() noexcept = default;
constexpr CTRE_FORCE_INLINE multi_subject_range(Range r) noexcept: range{r} { }
constexpr CTRE_FORCE_INLINE multi_subject_range(Range r) noexcept: range{r} { }

constexpr CTRE_FORCE_INLINE auto begin() const noexcept {
return iterator{range.begin(), range.end()};
Expand Down

0 comments on commit 3dec174

Please sign in to comment.