title: Getting a substring of a `std::string` between two iterators
body: <p>I have a program that's expected to take as input a few options to specify probabilities in the form (p1, p2, p3, ... ). So the command line usage would literally be:</p>
  
  <pre><code>./myprog -dist (0.20, 0.40, 0.40)
  </code></pre>
  
  <p>I want to parse lists like this in C++ and I am currently trying to do it with iterators for the std::string type and the split function provided by Boost.</p>
  
  <pre><code>// Assume stuff up here is OK
  std::vector&lt;string&gt; dist_strs; // Will hold the stuff that is split by boost.
  std::string tmp1(argv[k+1]);   // Assign the parentheses enclosed list into this std::string.
  
  // Do some error checking here to make sure tmp1 is valid.
  
  boost::split(dist_strs,  &lt;what to put here?&gt;   , boost::is_any_of(", "));
  </code></pre>
  
  <p>Note above the <code>&lt;what to put here?&gt;</code> part. Since I need to ignore the beginning and ending parentheses, I want to do something like</p>
  
  <pre><code>tmp1.substr( ++tmp1.begin(), --tmp1.end() )
  </code></pre>
  
  <p>but it doesn't look like <code>substr</code> works this way, and I cannot find a function in the documentation that works to do this.</p>
  
  <p>One idea I had was to do iterator arithmetic, if this is permitted, and use <code>substr</code> to call</p>
  
  <pre><code>tmp1.substr( ++tmp1.begin(), (--tmp1.end()) - (++tmp1.begin()) )
  </code></pre>
  
  <p>but I wasn't sure if this is allowed, or if it is a reasonable way to do it. If this isn't a valid approach, what is a better one? ...Many thanks in advance.</p>