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'
: _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::_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::_Optional_base' requested here
class optional
^
test.cpp:9:8: note: in implicit move constructor for 'std::optional' 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' is implicitly deleted because variant field '_M_payload' has a
non-trivial copy constructor
_Stored_type _M_payload;
这是有效的C++,还是WebKit坏了并且clang正确地拒绝了这段代码?
1> Barry..:
考虑这个课程:
struct X
{
X(int);
X(X&&) = delete;
// does this need to invoke the move constructor??
X() : X(X(0)) { }
};