title: Should you be able move from std::optional<T> where T has non-trivial constructors?
body: <p>I'm trying to compile WebKit with clang, and I'm hitting <a href="https://paste.ee/p/bkEZy" rel="noreferrer">compile errors</a> due to what is essentially the following pattern:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;optional&gt;
  
  struct X {
      X() = default;
      X(const X&amp; other) { }
  };
  
  struct Y {
      std::optional&lt;X&gt; x;;
  };
  
  int main() {
      Y foo;
      Y bar(std::move(foo));
  }
  </code></pre>
  
  <p>So, they use <code>std::optional&lt;T&gt;</code> where T (in their case, <code>WTF::Variant</code>) has non-trivial copy/move constructors, and then use the <code>std::optional</code> move constructor. This compiles fine with GCC 8.1.1, but not with clang 6.0.1 (using GCC 8.1.1's libstdc++):</p>
  
  <pre><code>In file included from test.cpp:2:
  /bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/optional:276:9: error: call to implicitly-deleted copy constructor of 'std::_Optional_payload&lt;X, true, true, true&gt;'
        : _Optional_payload(__engaged
          ^                 ~~~~~~~~~
  /bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/optional:739:4: note: in instantiation of member function 'std::_Optional_payload&lt;X, true, true, true&gt;::_Optional_payload' requested here
          : _M_payload(__other._M_payload._M_engaged,
            ^
  /bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/optional:985:11: note: in instantiation of member function 'std::_Optional_base&lt;X, false, false&gt;::_Optional_base' requested here
      class optional
            ^
  test.cpp:9:8: note: in implicit move constructor for 'std::optional&lt;X&gt;' first required here
  struct Y {
         ^
  test.cpp:15:7: note: in implicit move constructor for 'Y' first required here
      Y bar(std::move(foo));
        ^
  /bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/optional:288:24: note: copy constructor of '_Optional_payload&lt;X, true, true, true&gt;' is implicitly deleted because variant field '_M_payload' has a
        non-trivial copy constructor
            _Stored_type _M_payload;
  </code></pre>
  
  <p>Is this valid C++, or is WebKit broken and clang rightfully rejects this code?</p>