title: Is it possible to move a boost::optional?
body: <p>I've been trying to define a defaulted move constructor in a class with a <code>boost::optional</code> member variable.</p>
  
  <pre><code>#include &lt;boost/optional.hpp&gt;
  #include &lt;utility&gt;
  #include &lt;vector&gt;
  
  struct bar {std::vector&lt;int&gt; vec;};
  
  struct foo {
    foo() = default;
    foo(foo&amp;&amp;) = default;
    boost::optional&lt;bar&gt; hello;
  };
  
  int main() {
    foo a;
    foo b(std::move(a));
  }
  </code></pre>
  
  <p>My compiler supports both move semantics and defaulted move constructors, but I cannot get this to work.</p>
  
  <blockquote>
  <pre><code>% clang++ foo.cc -std=c++11 -stdlib=libc++
  foo.cc:15:7: error: call to deleted constructor of 'foo'
    foo b(std::move(a));
        ^ ~~~~~~~~~~~~
  foo.cc:9:3: note: function has been explicitly marked deleted here
    foo(foo&amp;&amp;) = default;
    ^
  1 error generated.
  </code></pre>
  </blockquote>
  
  <p>Is there a way to move a <code>boost::optional</code> <em>without</em> modifying Boost's source code? Or should I wait until Boost supports moving?</p>
  
  <p>I had the same problem with <code>boost::any</code> in the past.</p>