I’m trying to find an elegant way to find some text ex. "hello world" from the sentence "I compiled my first hello world. It works!"
But the sentence is a std::list<word> with some metadata.
Class Word
{
std::string m_word;
Location ... (X,Y in a picture)
....
}
Just wondering if there is nice way to do that with some std or boost functions rather than my 2 ugly loops. Thanks!
You can use
std::searchtogether with a custom predicate that only compares them_wordmember:This code assumes a
getWordmethod and a constructorWord(const char*)for the array initialization.