title: Preserving insertion order on a std::set or std::unordered_set
body: <p>Before marking this as duplicate, I have been <a href="https://stackoverflow.com/questions/1098175/a-stdmap-that-keep-track-of-the-order-of-insertion">here</a>, <a href="https://stackoverflow.com/questions/31942783/need-stl-set-in-insertion-order">here</a>, and <a href="https://stackoverflow.com/questions/6278580/stl-container-that-preserves-order-of-insertion-but-allows-no-duplicates">here, a duplicate of the first</a>.</p>
  
  <p>I'm aware of <code>boost::multi_index</code>, and use an environment where I lack it, and that a <code>std::unordered_set</code> is not bound to store elements in a deterministic insertion order.</p>
  
  <p>I find the concept of using two containers, say an additional <code>std::vector</code> as uncouth.</p>
  
  <p>What I <em>would love</em> is a solution involving a comparator that I can use in a <code>std::set</code>'s template parameters (clarification, this could be a trivial functor struct, containing a <code>bool operator()()</code> overload, a regular function, or a lambda). Is it possible?</p>
  
  <h3>Addenda</h3>
  
  <ol>
  <li><p>Initialization must occur through a std:: container's begin iterator/end iterator constructor, such as in this snippet.</p>
  
  <pre><code>std::string str; cin &gt;&gt; str;
  std::set&lt;char&gt;(str.begin(), str.end());
  </code></pre></li>
  <li><p>Also, another interesting use-case would be to create a dumb hash wrapping functor that allows insertion order to be pushed in to a <code>std::unordered_set</code>'s template parameter.</p></li>
  </ol>