MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::slices::SplitOneOfIter< T > Struct Template Reference

#include <slice_algo.hpp>

Collaboration diagram for mtcore::slices::SplitOneOfIter< T >:

Public Member Functions

Optional< Pair< Slice< T >, Optional< std::remove_const_t< T > > > > next ()
 

Public Attributes

Slice< std::add_const_t< T > > needles
 
Slice< T > haystack
 
Optional< std::remove_const_t< T > > foundNeedle = nullopt
 
bool emittedLast = true
 

Detailed Description

template<typename T>
struct mtcore::slices::SplitOneOfIter< T >

Definition at line 546 of file slice_algo.hpp.

Member Function Documentation

◆ next()

template<typename T>
Optional< Pair< Slice< T >, Optional< std::remove_const_t< T > > > > mtcore::slices::SplitOneOfIter< T >::next ( )
inline

Definition at line 552 of file slice_algo.hpp.

552 {
553 if (haystack.empty()) {
554 mtdefer { emittedLast = true; };
555 if (emittedLast) {
556 return nullopt;
557 }
559 }
560
562 if (!nxt.has_value()) {
563 mtdefer {
565 haystack = haystack.sub(haystack.size());
566 emittedLast = true;
567 };
569 }
570
571 mtdefer {
572 foundNeedle = haystack[nxt.value()];
573 haystack = haystack.sub(nxt.value() + 1);
574 emittedLast = false;
575 };
576
577 return make_pair(haystack.sub(0, nxt.value()), foundNeedle);
578 }
Pair< T1, T2 > make_pair(T1 first, T2 second)
Helper to make a pair with type inference.
Definition pair.hpp:45
mtcore::Optional< size_t > first_index_one_of(const Slice< T > &needles, const Slice< T > &haystack)
Gets the first index that one of the provided needles appears in the haystack, or nullopt if the need...
Slice< std::add_const_t< T > > needles
Optional< std::remove_const_t< T > > foundNeedle
Here is the call graph for this function:

Member Data Documentation

◆ emittedLast

template<typename T>
bool mtcore::slices::SplitOneOfIter< T >::emittedLast = true

Definition at line 550 of file slice_algo.hpp.

◆ foundNeedle

template<typename T>
Optional<std::remove_const_t<T> > mtcore::slices::SplitOneOfIter< T >::foundNeedle = nullopt

Definition at line 549 of file slice_algo.hpp.

◆ haystack

template<typename T>
Slice<T> mtcore::slices::SplitOneOfIter< T >::haystack

Definition at line 548 of file slice_algo.hpp.

◆ needles

template<typename T>
Slice<std::add_const_t<T> > mtcore::slices::SplitOneOfIter< T >::needles

Definition at line 547 of file slice_algo.hpp.


The documentation for this struct was generated from the following file: