Split range adaptors#10
Conversation
There was a problem hiding this comment.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
pre-commit
[pre-commit] reported by reviewdog 🐶
str_split/tests/beman/str_split/split_when.tests.cpp
Lines 58 to 60 in ba5f322
|
|
||
| namespace beman::str_split::detail { | ||
|
|
||
| template<class Parent> |
There was a problem hiding this comment.
[pre-commit] reported by reviewdog 🐶
| template<class Parent> | |
| template <class Parent> |
| template<class Parent> | ||
| class split_iterator | ||
| { |
There was a problem hiding this comment.
[pre-commit] reported by reviewdog 🐶
| template<class Parent> | |
| class split_iterator | |
| { | |
| template <class Parent> | |
| class split_iterator { |
| public: | ||
| using iterator_concept = std::forward_iterator_tag; |
There was a problem hiding this comment.
[pre-commit] reported by reviewdog 🐶
| public: | |
| using iterator_concept = std::forward_iterator_tag; | |
| public: | |
| using iterator_concept = std::forward_iterator_tag; |
| using value_type = Parent::base_subrange; | ||
| using difference_type = std::iter_difference_t<base_iterator>; |
There was a problem hiding this comment.
[pre-commit] reported by reviewdog 🐶
| using value_type = Parent::base_subrange; | |
| using difference_type = std::iter_difference_t<base_iterator>; | |
| using value_type = Parent::base_subrange; | |
| using difference_type = std::iter_difference_t<base_iterator>; |
| : parent_(std::addressof(parent)) | ||
| , current_(std::move(current)) | ||
| , next_(std::move(next)) | ||
| { | ||
| } |
There was a problem hiding this comment.
[pre-commit] reported by reviewdog 🐶
| : parent_(std::addressof(parent)) | |
| , current_(std::move(current)) | |
| , next_(std::move(next)) | |
| { | |
| } | |
| : parent_(std::addressof(parent)), current_(std::move(current)), next_(std::move(next)) {} |
| V operator()(V view) | ||
| { | ||
| auto str = std::string_view(view); |
There was a problem hiding this comment.
[pre-commit] reported by reviewdog 🐶
| V operator()(V view) | |
| { | |
| auto str = std::string_view(view); | |
| V operator()(V view) { | |
| auto str = std::string_view(view); |
| return {std::ranges::begin(view) + begin_pos, std::ranges::begin(view) + end_pos}; | ||
| } | ||
|
|
||
| private: |
There was a problem hiding this comment.
[pre-commit] reported by reviewdog 🐶
| private: | |
| private: |
| std::string_view delimiters_; | ||
| }; | ||
|
|
||
| } |
There was a problem hiding this comment.
[pre-commit] reported by reviewdog 🐶
| } | |
| } // namespace |
| auto words = ""sv | ||
| | bss::views::split_when(any_seq_of(" \t"sv)) | ||
| | std::ranges::to<std::vector<std::string>>(); |
There was a problem hiding this comment.
[pre-commit] reported by reviewdog 🐶
| auto words = ""sv | |
| | bss::views::split_when(any_seq_of(" \t"sv)) | |
| | std::ranges::to<std::vector<std::string>>(); | |
| auto words = ""sv | bss::views::split_when(any_seq_of(" \t"sv)) | std::ranges::to<std::vector<std::string>>(); |
| auto parts = "Down the Rabbit-Hole"sv | ||
| | bss::views::split_when(any_seq_of("-."sv)) | ||
| | std::ranges::to<std::vector<std::string>>(); |
There was a problem hiding this comment.
[pre-commit] reported by reviewdog 🐶
| auto parts = "Down the Rabbit-Hole"sv | |
| | bss::views::split_when(any_seq_of("-."sv)) | |
| | std::ranges::to<std::vector<std::string>>(); | |
| auto parts = "Down the Rabbit-Hole"sv | bss::views::split_when(any_seq_of("-."sv)) | | |
| std::ranges::to<std::vector<std::string>>(); |
Coverage Report for CI Build 27112801698Warning No base build found for commit Coverage: 96.491%Details
Uncovered Changes
Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
beman::str_split::split_when_viewis a range adaptor based onstd::ranges::split_viewthat splits a view on delimiters found by the provided search function. The search function takes the remaining sub-range to search as input, and returns the nested sub-range around the next delimiter.I've also implemented
std::range::split_viewasbeman::str_split::split_view. I haven't written range adaptors before, so this was a good learning exercise.beman::str_split::split_when_viewstill has all the same ergonomic issues thatstd::ranges::split_viewhas W.R.T working with strings. Nonetheless, I still think this is a useful starting point for range-based splitting.I've not made an attempt to use modules yet. Everything is header based. I do want to support modules, I just haven't take the time to learn how to use them.