title: Using std::search to find multiple occurrence of pattern
body: <p>I want to use function search or other similar function to find multiple occurrence of given pattern. </p>
  
  <p>This is my code:</p>
  
  <pre><code>#include &lt;cstring&gt;  
  #include &lt;iostream&gt; 
  #include &lt;iomanip&gt;  
  #include &lt;set&gt;
  #include &lt;list&gt;
  #include &lt;vector&gt;
  #include &lt;map&gt;   
  #include &lt;algorithm&gt;
  #include &lt;functional&gt;
  using namespace std;
  
  int main () {
    std::vector&lt;int&gt; haystack;
  
    string a = "abcabcabc";
    string b = "abc";
    string::iterator it;
    it = search(a.begin(),a.end(),b.begin(),b.end());
  
    if(it!=a.end()){
        cout &lt;&lt; it-a.begin()&lt;&lt;endl;
    }
  
    return 0;
  }
  </code></pre>
  
  <p>This code return 0 as the first occurrence of pattern "abc" , would like to return 0, 3, 6. That would be all of the indexes in the original string where pattern begins. </p>
  
  <p>Thank you for any help.</p>