<div dir="ltr">Hi,<div>If you construct with copy, the copy constructor is used.</div><div>The insert operation works<span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span> </span>(I think)</span> by copying new items over the old items, not by constructing new items, so the copy assignment is needed (if not the move iterator is used).</div></div><br><div class="gmail_quote"><div dir="ltr">Nikita Alekseev via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> ezt írta (időpont: 2018. júl. 3., K, 14:05):<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><blockquote type="cite"></blockquote><blockquote type="cite"><blockquote type="cite">Hello everyone, I hope this mailing list is the right place to ask about<br>this. When I try to compile this particular code<br>sample <a href="https://godbolt.org/g/J7cgbV" target="_blank">https://godbolt.org/g/J7cgbV</a> I get an error, that A must have a<br>copy assignment operator. However when reading the documentation<br>at <a href="https://en.cppreference.com/w/cpp/container/vector/insert" target="_blank">https://en.cppreference.com/w/cpp/container/vector/insert</a> I do not<br>see any such requirements for this particular overload of insert. It<br>does mention that T must be moveAssignable and MoveInsertable if<br>Iterator is not ForwardIterator. Even if I define move assignment<br>operator it still requires copy assignment.<br><br>I have tested it on Clang 4, Clang 6, GCC 8.1 and get the same error.<br>MSVC 2017 compiles when move assignment is present. It would be great if<br>someone could explain this behavior.<br></blockquote><br>hi,<br>please look at:<br><a href="https://en.cppreference.com/w/cpp/iterator/make_move_iterator" target="_blank">https://en.cppreference.com/w/cpp/iterator/make_move_iterator</a></blockquote><br><div>I am afraid this is not what I am trying to achieve. I want to copy vector contents via insert, but why it requires copy assignment to be defined in order to compile? Simple construction from the pair of iterators works without it.</div></div>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>