title: What is the exact way of using regex_iterator in C++?
body: <p>I have been looking for a good way to calculate the number of sub-strings of a particular type in a string, say, I want to count the occurrences of 'sms' in the string 'smstyuismsms'. I found an answer in a forum where somebody suggested making use of regex_iterator. But, when I tried it as follows:</p>
  
  <pre><code>string in = "smstyuismssms";
  cout &lt;&lt; distance(regex_iterator(in.begin(), in.end(), regex("sms")),regex_iterator()) &lt;&lt; "\n";
  </code></pre>
  
  <p>It throws an error saying</p>
  
  <blockquote>
    <p>error: missing template arguments before '(' token</p>
  </blockquote>
  
  <p>So, if not this, then what is the correct way of using regex template? Please provide some examples as well.</p>