[Bug libstdc++/80451] return implicit type conversion to std::experimental::optional does not compile
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Apr 18 10:35:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80451
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ville at gcc dot gnu.org
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is due to the resolution of
http://cplusplus.github.io/LWG/lwg-defects.html#2451
#include <experimental/optional>
class B {
public:
B(const B&) = delete;
B(B&&) { }
B& operator=(const B&) = delete;
B& operator=(B&&) = delete;
B() noexcept {};
};
inline std::experimental::optional<B>
meal() {
B b;
return b;
}
int main() {
auto k = meal();
}
The example tries to construct optional<B> from an lvalue of type B, which
would require a copy, which is deleted. Doing "return std::move(b);" would
work.
More information about the Gcc-bugs
mailing list