...
This commit is contained in:
@@ -65,22 +65,23 @@ struct AdcStopSeqSessionProto {
|
||||
|
||||
|
||||
template <std::input_iterator IT>
|
||||
std::pair<IT, bool> search(IT begin, IT end)
|
||||
auto search(IT begin, IT end)
|
||||
{
|
||||
auto res = std::make_pair(begin, false);
|
||||
std::tuple<IT, IT, bool> res{begin, end, false};
|
||||
|
||||
if (begin == end) {
|
||||
return res;
|
||||
}
|
||||
|
||||
res.first = std::search(begin, end, STOP_SEQ.begin(), STOP_SEQ.end());
|
||||
if (res.first != end) {
|
||||
std::advance(res.first, STOP_SEQ_SIZE); // move iterator to the one-past-the-end position
|
||||
res.second = true;
|
||||
auto it = std::search(begin, end, STOP_SEQ.begin(), STOP_SEQ.end());
|
||||
if (it != end) {
|
||||
// std::advance(it, STOP_SEQ_SIZE); // move iterator to the one-past-the-end position
|
||||
std::get<1>(res) = it + STOP_SEQ_SIZE;
|
||||
std::get<2>(res) = true;
|
||||
} else {
|
||||
// may be only a part of valid byte sequence was received,
|
||||
// so start next matching from previous begin-iterator
|
||||
res.first = begin;
|
||||
std::get<1>(res) = begin;
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
Reference in New Issue
Block a user