<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 29, 2016, at 10:36 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Tue, Mar 29, 2016 at 6:20 PM, Mehdi AMINI via llvm-commits<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><span class="">joker.eph added inline comments.<br class=""><br class="">================<br class=""></span><span class="">Comment at: include/llvm/ADT/StringMap.h:248<br class="">@@ -246,2 +247,3 @@<br class=""><br class=""></span><span class="">-  // FIXME: Implement copy operations if/when they're needed.<br class="">+  StringMap(const StringMap &RHS) :<br class="">+    StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))),<br class=""></span><span class="">----------------<br class="">hfinkel wrote:<br class="">> joker.eph wrote:<br class=""></span>> > May be explicit?<br class="">> I don't think that I can -- I need the copy-initialization support for:<br class="">><br class="">>   CustomNameFuncs = TLI.CustomNameFuncs;<br class="">><br class="">> in D18513.<br class="">The issue is only because the copy assignment operator is defined as:<br class="">```<br class="">StringMap &operator=(StringMap RHS) {<br class="">   <span class="Apple-converted-space"> </span>StringMapImpl::swap(RHS);<br class="">   <span class="Apple-converted-space"> </span>std::swap(Allocator, RHS.Allocator);<br class="">   <span class="Apple-converted-space"> </span>return *this;<br class=""> <span class="Apple-converted-space"> </span>}<br class="">```<br class=""><br class="">I think we could change it to:<br class=""><br class="">```<br class="">StringMap &operator=(const StringMap &RHS) {<br class="">   <span class="Apple-converted-space"> </span>StringMap Tmp(RHS);<br class="">   <span class="Apple-converted-space"> </span>StringMapImpl::swap(Tmp);<br class="">   <span class="Apple-converted-space"> </span>std::swap(Allocator, Tmp.Allocator);<br class="">   <span class="Apple-converted-space"> </span>return *this;<br class=""> <span class="Apple-converted-space"> </span>}<br class="">StringMap &operator=(const StringMap &&RHS) {<br class="">   <span class="Apple-converted-space"> </span>std::swap(Allocator, std::move(RHS.Allocator));<br class="">   <span class="Apple-converted-space"> </span>StringMapImpl::swap(std::move(RHS));<br class="">   <span class="Apple-converted-space"> </span>return *this;<br class=""> <span class="Apple-converted-space"> </span>}<br class=""></blockquote><div class=""><br class=""></div><div class="">That would be a somewhat scary move op - leaving possibly large allocations in the moved-from object... </div></div></div></blockquote><div><br class=""></div><div>Oh yeah forgot to move-construct a temp to force the destructore to run ASAP...</div><div>(and I'd probably implement a swap operator to avoid the code duplication)</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">```<br class=""><br class="">Now the only thing that it buys us is a protection against unexpected/unintended copy construction for a StringMap, is it compelling enough?<br class=""></blockquote><div class=""><br class=""></div><div class="">Yeah, I'd be pretty uncomfortable making a copy ctor explicit - I'm with Hal here. Make things obvious value types & leave it up to users to choose when to copy or not, etc</div></div></div></blockquote><div><br class=""></div><div>I would agree if there was a way to express intent at call site in C++, it's all implicit. We can agree to disagree philosophically here :)</div><div><br class=""></div><div>-- </div><div>Mehdi</div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="">. (I've seen codebases that try to make copies explicit operations (even named functions) - Google's style guide no longer has any such wording/discouragement & that's for the best, I think)</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div class="HOEnZb"><div class="h5"><br class=""><br class=""><br class=""><a href="http://reviews.llvm.org/D18506" rel="noreferrer" target="_blank" class="">http://reviews.llvm.org/D18506</a><br class=""><br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a></div></div></blockquote></div></div></blockquote></div><br class=""></body></html>