c++ - Find substring in string with iterators -
i have substring defined 2 iterators (start
, end
). need check if substring present in string.
is there standard library algorithm or string member can use or adapt without creating whole new string object (std::string(start, end)
) purpose?
e.g.
struct substring { std::string::const_iterator start, end; }; auto found = std::contains(whole.begin(), whole.end(), substring.start, substring.end); // ???
bool found = std::search(hay.begin(), hay.end(), needle.begin(), needle.end()) != hay.end();
Comments
Post a Comment