title: Safer but easy-to-use and flexible C++ alternative to sscanf()
body: <p>When I need to scan in values from a bunch of strings, I often find myself falling back to C's <code>sscanf()</code> strictly because of its simplicity and ease of use. For example, I can very succinctly pull a couple double values out of a string with:</p>
  
  <pre><code>string str;
  double val1, val2;
  if (sscanf(str.c_str(), "(%lf,%lf)", &amp;val1, &amp;val2) == 2)
  {
      // got them!
  }
  </code></pre>
  
  <p>This obviously isn't very C++. I don't necessarily consider that an abomination, but I'm always looking for a better way to do a common task. I understand that the "C++ way" to read strings is <code>istringstream</code>, but the extra typing required to handle the parenthesis and comma in the format string above just make it too cumbersome to make me want to use it.</p>
  
  <p>Is there a good way to either bend built-in facilities to my will in a way similar to the above, or is there a good C++ library that does the above in a more type-safe way? It looks like Boost.Format has really solved the output problem in a good way, but I haven't found anything similarly succinct for input.</p>