title: parsing command-line options with sequence containers?
body: <p>This question has come up before, but it seems that none of the answers provide alternatives with <code>boost</code>-style generic programming.</p>
  
  <p>Like many I use boost:program_options to parse command line line options. My current project is a program to manipulate data (e.g. images) with operators whose order is not interchangeable, <em>e.g.</em></p>
  
  <p><em>add 3 then multiply by 2</em><br>
  <code>$ manipulate -in someimage.tif -a 3 -m 2</code></p>
  
  <p>is not generally the same as</p>
  
  <p><em>multiply by 2 then add 3</em><br>
  <code>$ manipulate -in someimage.tif -m 2 -a 3</code></p>
  
  <p>The <code>-in</code> option loads the file contents into a vector <code>current_image</code>, and each option on the command line modifies <code>current_image</code>. </p>
  
  <p>But the <code>variable_map</code> container does not retain the order in which options are added. Not explicitly, at least. The answer in <a href="https://stackoverflow.com/questions/11769550">this post</a> comes closest to what I have in mind, but then the amount of <a href="https://coderwall.com/p/y3xnxg/using-getopt-vs-boost-in-c-to-handle-arguments" rel="nofollow noreferrer">extra parsing code needed</a> is about the same as with <code>getopt()</code>.</p>
  
  <p>Does anyone know a way to store the order of program options in the boost-provided container? Is it fundamentally impossible? Or is it possible (maybe even implemented) with a sequence container?</p>
  
  <p><em>EDIT 1</em> I did find this <a href="http://boost.2283326.n4.nabble.com/program-options-iterate-variable-map-td2556563.html" rel="nofollow noreferrer">really old post</a> which seems still valid, stating that yes you can just iterate over a variables_map. Of course the order is not actually specified to be the same as the order on the command line (left to the compiler writers), so I guess it does still classify as a hack.<br>
  <em>EDIT 2</em> That is not enough as the options are sorted by option string so the iteration order is not the same as the insertion order.</p>