This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/80451] return implicit type conversion to std::experimental::optional does not compile


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]