title: Expression: string iterator not dereferencable while using boost regex
body: <p>I want to recover all the links from a page, while executing this code I get:</p>
  
  <blockquote>
    <p>Microsoft Visual C++ Debug Library</p>
    
    <p>Debug Assertion Failed!</p>
    
    <p>Program: C:\Users\Gandalf\Desktop\proxy\Debug\Proxy.exe File:
    C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xstring Line:
    78</p>
    
    <p>Expression: string iterator not dereferencable</p>
    
    <p>For information on how your program can cause an assertion failure,
    see the Visual C++ documentation on asserts.</p>
    
    <p>(Press Retry to debug the application)</p>
    
    <p>Abort   Retry   Ignore</p>
  </blockquote>
  
  <pre><code>void Deltacore::Client::get_links() {
  boost::smatch matches;
  boost::match_flag_type flags = boost::match_default;
  boost::regex URL_REGEX("^&lt;a[^&gt;]*(http://[^\"]*)[^&gt;]*&gt;([ 0-9a-zA-Z]+)&lt;/a&gt;$");
  
  if(!response.empty()) {
  
      std::string::const_iterator alfa = this-&gt;response.begin();
      std::string::const_iterator omega   = this-&gt;response.end();
  
      while (boost::regex_search(alfa, omega, matches, URL_REGEX))
      {
          std::cout &lt;&lt; matches[0];
          //if(std::find(this-&gt;Links.begin(), this-&gt;Links.end(), matches[0]) != this-&gt;Links.end()) {
              this-&gt;Links.push_back(matches[0]);
          //}
          alfa = matches[0].second;
      }
  }
  }
  </code></pre>
  
  <p>Any Ideea?</p>
  
  <p>Added more code:</p>
  
  <pre><code>        Deltacore::Client client;
      client.get_url(target);
      client.get_links();
  
              boost::property_tree::ptree props;
              for(size_t i = 0; i &lt; client.Links.size(); i++)
                  props.push_back(std::make_pair(boost::lexical_cast&lt;std::string&gt;(i), client.Links.at(i)));
  
              std::stringstream ss;
              boost::property_tree::write_json(ss, props, false);
  
              boost::asio::async_write(socket_,
                  boost::asio::buffer(ss.str(), ss.str().length()),
                  boost::bind(&amp;session::handle_write, this,
                  boost::asio::placeholders::error));
  </code></pre>
  
  <p>Thanks in advance</p>