[llvm-bugs] [Bug 36703] New: std::map copy assignment fails for mapped types without copy assignment
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Mar 13 10:23:02 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=36703
Bug ID: 36703
Summary: std::map copy assignment fails for mapped types
without copy assignment
Product: libc++
Version: 6.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: plroskin at gmail.com
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
I've noticed that a program I'm working on would compile with libstdc++ but not
with libc++. Here's a minimal version:
#include <map>
struct Mapped
{
Mapped() {};
Mapped(const Mapped&) = default;
Mapped(Mapped&&) = delete;
Mapped& operator=(const Mapped&) = delete;
Mapped& operator=(Mapped&&) = delete;
~Mapped() = default;
};
using MyMap = std::map<int, Mapped>;
int main()
{
const MyMap map1{};
MyMap map2{};
map2 = map1;
// this would work:
// map2 = MyMap{map1};
return 0;
}
clang 6 would complain:
/opt/clang-6.0.0/bin/../include/c++/v1/map:629:15: error: object of type
'std::__1::pair<int, Mapped>' cannot be assigned because its copy assignment
operator is implicitly deleted
{__nc = __v.__cc; return *this;}
I see that a similar bug #23304 was closed as invalid. Still, I believe there
is a room for improvement here for libc++ to be a drop-in replacement for
libstdc++. Maybe there should be a fallback copy assignment implementation that
avoids using copy assignment for the mapped type.
I would have hard time explaining to my colleagues why I need to create a
temporary map object to placate libc++.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180313/dc50a0d5/attachment.html>
More information about the llvm-bugs
mailing list