Honestly, your implementation is so much more complicated that it needs to be. I gave up after looking through it.
Here is a quick implementation I made that works:
Code:
bool containsStr(const string& sourceStr, const string& searchStr)
{
if (searchStr.size() > sourceStr.size())
return false; //since it is not possible for sourceStr to fully contain searchStr since it is shorter
const auto src_end = sourceStr.end(), dst_end = searchStr.end();
for (auto src_it = sourceStr.begin(), dst_it = searchStr.begin(); src_it < src_end; ++src_it)
{
if (*src_it == *dst_it)
{
++src_it;
for (auto dst_it2 = dst_it + 1; dst_it2 < dst_end; ++dst_it2, ++src_it)
{
if (*dst_it2 != *src_it)
break;
}
return true;
}
}
return false;
}
Now compare that to yours.