This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/80451] return implicit type conversion to std::experimental::optional does not compile
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 18 Apr 2017 10:35:16 +0000
- Subject: [Bug libstdc++/80451] return implicit type conversion to std::experimental::optional does not compile
- Auto-submitted: auto-generated
- References: <bug-80451-4@http.gcc.gnu.org/bugzilla/>
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.