|
Boost : |
From: Jonathan Wakely (cow_at_[hidden])
Date: 2005-03-24 10:50:02
On Thu, Mar 24, 2005 at 09:27:51AM -0600, Michael Goldshteyn wrote:
> Given:
>
> typedef std::deque<char> DequeString;
> std::string s("Hello sweet world!");
> std::string word("sweet");
> DequeString dequeString;
>
> // Copy "Hello sweet world!" into the deque string
> std::copy(s.begin(),s.end(),std::back_inserter(dequeString));
>
> // Now, I want to find where "sweet" appears in the dequeString. An iterator
> to its location would be fine.
>
> // This doesn't quite do it, since it looks for _any_ occurrence of a
> character from word in dequeString
> std::find_first_of(dequeString.begin(),dequeString.end(),word.begin(),word.end());
>
> // But, I want to find where _the whole_ word occurs in dequeString, similar
> to how std::string::find() does it:
> std::string::size_type wordPos=s.find(word);
>
> Is there something in boost or the standard C++ lib that can be used?
std::search()
jon
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk