| 749 | |
| 750 | template <class Base> |
| 751 | class TSplitRange: public Base, public TInputRangeAdaptor<TSplitRange<Base>> { |
| 752 | using TStringBufType = decltype(std::declval<Base>().Next()->Token()); |
| 753 | |
| 754 | public: |
| 755 | template <typename... Args> |
| 756 | inline TSplitRange(Args&&... args) |
| 757 | : Base(std::forward<Args>(args)...) |
| 758 | { |
| 759 | } |
| 760 | |
| 761 | template <class Consumer, std::enable_if_t<std::is_same<decltype(std::declval<Consumer>()(std::declval<TStringBufType>())), void>::value, int>* = nullptr> |
| 762 | inline void Consume(Consumer&& f) { |
| 763 | for (auto&& it : *this) { |
| 764 | f(it.Token()); |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | template <class Consumer, std::enable_if_t<std::is_same<decltype(std::declval<Consumer>()(std::declval<TStringBufType>())), bool>::value, int>* = nullptr> |
| 769 | inline bool Consume(Consumer&& f) { |
| 770 | for (auto&& it : *this) { |
| 771 | if (!f(it.Token())) { |
| 772 | return false; |
| 773 | } |
| 774 | } |
| 775 | return true; |
| 776 | } |
| 777 | |
| 778 | template <class Container, class = std::enable_if_t<THasInsert<Container>::value || THasPushBack<Container>::value>> |
| 779 | operator Container() { |
| 780 | Container result; |
| 781 | AddTo(&result); |
| 782 | return result; |
| 783 | } |
| 784 | |
| 785 | template <class S> |
| 786 | inline TVector<S> ToList() { |
| 787 | TVector<S> result; |
| 788 | for (auto&& it : *this) { |
| 789 | result.push_back(S(it.Token())); |
| 790 | } |
| 791 | return result; |
| 792 | } |
| 793 | |
| 794 | template <class Container> |
| 795 | inline void Collect(Container* c) { |
| 796 | Y_ASSERT(c); |
| 797 | c->clear(); |
| 798 | AddTo(c); |
| 799 | } |
| 800 | |
| 801 | template <class Container> |
| 802 | inline void AddTo(Container* c) { |
| 803 | Y_ASSERT(c); |
| 804 | TContainerConsumer<Container> consumer(c); |
| 805 | Consume(consumer); |
| 806 | } |
| 807 | |
| 808 | template <class Container> |
nothing calls this directly
no test coverage detected