<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - std::map copy assignment fails for mapped types without copy assignment"
   href="https://bugs.llvm.org/show_bug.cgi?id=36703">36703</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>std::map copy assignment fails for mapped types without copy assignment
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>plroskin@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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 <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - map<const, const> fails copy-assignment"
   href="show_bug.cgi?id=23304">bug #23304</a> 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++.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>