This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/81190] New: std::optional doesn't compile with containers that have noncopyable types
- From: "lyberta at lyberta dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 23 Jun 2017 15:01:57 +0000
- Subject: [Bug libstdc++/81190] New: std::optional doesn't compile with containers that have noncopyable types
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81190
Bug ID: 81190
Summary: std::optional doesn't compile with containers that
have noncopyable types
Product: gcc
Version: 7.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: lyberta at lyberta dot net
Target Milestone: ---
The following code will compile perfectly with std::experimental::optional but
will produce compiler errors with std::optional:
#include <iostream>
#include <optional>
#include <memory>
#include <map>
class Foo
{
public:
Foo(std::unique_ptr<int> a)
{
m1.emplace(42, std::move(a));
}
private:
std::map<int, std::unique_ptr<int>> m1;
};
int main()
{
std::optional<Foo> opt;
opt.emplace(std::make_unique<int>(42));
opt = std::nullopt;
}