title: boost::optional not letting me reassign const value types
body: <p>It seems to me there should be four variants of <code>boost::optional</code></p>
  
  <ul>
  <li><p><code>optional&lt;Foo&gt;</code> => holds a mutable Foo and can be reassigned after initialization</p></li>
  <li><p><code>optional&lt;Foo const&gt; const</code> => holds a const Foo and can't be reassigned after initialization</p></li>
  <li><p><code>optional&lt;Foo&gt; const</code> => (should?) hold a mutable Foo but can't be reassigned after initialization</p></li>
  <li><p><code>optional&lt;Foo const&gt;</code> => (should?) hold a const Foo and can be reassigned after initialization</p></li>
  </ul>
  
  <p>The first 2 cases work as expected.  But the <code>optional&lt;Foo&gt; const</code> dereferences to a const Foo, and the <code>optional&lt;Foo const&gt;</code> doesn't allow reassignment after initialization (as touched upon in <a href="https://stackoverflow.com/questions/2306645/using-boostoptional-with-constant-types-c">this question</a>).</p>
  
  <p>The reassignment of the const value types is specifically what I ran into, and the error is:</p>
  
  <blockquote>
    <p>/usr/include/boost/optional/optional.hpp:486: error: passing ‘const Foo’ as ‘this’ argument of ‘Foo&amp; Foo::operator=(const Foo&amp;)’ discards qualifiers [-fpermissive]</p>
  </blockquote>
  
  <p>And it happens here:</p>
  
  <pre><code>void assign_value(argument_type val,is_not_reference_tag) { get_impl() = val; }
  </code></pre>
  
  <p>After construction, the implementation uses the assignment operator for the type you parameterized the optional with.  It obviously doesn't want a left-hand operand which is a const value.  But why shouldn't you be able to reset a non-const optional to a new const value, such as in this case:</p>
  
  <pre><code>optional&lt;Foo const&gt; theFoo (maybeGetFoo());
  while (someCondition) {
  
      // do some work involving calling some methods on theFoo
      // ...but they should only be const ones
  
      theFoo = maybeGetFoo();
  }
  </code></pre>
  
  <p>Some Questions:</p>
  
  <ul>
  <li><p>Am I right that wanting this is conceptually fine, and not being able to do it is just a fluke in the implementation?</p></li>
  <li><p>If I don't edit the boost sources, what would be a clean way to implement logic like in the loop above without scrapping boost::optional altogether?</p></li>
  <li><p>If this does make sense and I were to edit the boost::optional source (which I've already had to do to make it <a href="https://stackoverflow.com/questions/10783391/is-it-possible-to-move-a-boostoptional">support movable types</a>, though I suspect they'll be doing that themselves soon) then what minimally invasive changes might do the trick?</p></li>
  </ul>