I'm currently making a DLL with a collection of code snippets that I find myself commonly using. I have made a search functin that checks if one string is inside of another string. I have also added a vector choice in the case that I want to search many strings.
In the header:
static DATAEDITING_API bool Contains(std::string target, std::string source);
static DATAEDITING_API bool Contains(std::string target, std::vector<std::string> source);
static DATAEDITING_API bool Contains(std::string target, std::string source, bool sensitive);
static DATAEDITING_API bool Contains(std::string target, std::vector<std::string> source, bool sensitive);
Now the problem is that the following code snippet always returns true. The Contains(std::string, std::string, bool) function has been tested to work properly; testing was for: an outright false case, a case dependent on case (both conditions tested) and a case where the start of the target string was found toward the end of the search string (ie "insert" in "thin").
bool Editor::StringHandler::Contains(std::string target, std::vector<std::string> source, bool sensitive)
{
for (std::string i : source)
{
if(Contains(target, i, sensitive)){return true;}
}
return false;
}
Any ideas on why the function always returns true?