c++ - Finding a substring passing only 2 iterators? -


i have curious problem. fix goes high performance library. 1 of tasks change interface use internal string descriptor format pointer , length instead of std string parameters. 1 of functions search , find pattern within string , copy rest of string after pattern buffer.

i added change of assigning entire iterator range buffer{ custom allocator version of std string } , erasing characters upto pattern. fix rejected saying better.

my problem this. input string pair of iterators. may or may not own byte pointed end iterator i.e. cannot dereference safely.

the pattern

std::find(start, end, value); 

does not allow value string.

strstr(start, value); 

takes null terminated string. code has linkage boost. there boost utilities or stl algorithms take 2 string iterators , return iterator pointing first byte of string pattern. of course. there brain dead solution of creating temporary string , reassigning.

can avoid allocations?

std::search(begin, end, pat_begin, pat_end); 

does job me. please give more suggestions if possible.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -