<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 13, 2014 at 3:23 PM, Duncan P. N. Exon Smith <span dir="ltr"><<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dexonsmith<br>
Date: Thu Nov 13 17:23:02 2014<br>
New Revision: 221946<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=221946&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=221946&view=rev</a><br>
Log:<br>
ADT: Use perfect forwarding in StringMapEntry::Create()<br>
<br>
Now you can pass references into constructors.<br></blockquote><div><br></div><div>Unit test?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
    llvm/trunk/include/llvm/ADT/StringMap.h<br>
<br>
Modified: llvm/trunk/include/llvm/ADT/StringMap.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=221946&r1=221945&r2=221946&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=221946&r1=221945&r2=221946&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ADT/StringMap.h (original)<br>
+++ llvm/trunk/include/llvm/ADT/StringMap.h Thu Nov 13 17:23:02 2014<br>
@@ -117,8 +117,9 @@ public:<br>
<br>
   explicit StringMapEntry(unsigned strLen)<br>
     : StringMapEntryBase(strLen), second() {}<br>
-  StringMapEntry(unsigned strLen, ValueTy V)<br>
-      : StringMapEntryBase(strLen), second(std::move(V)) {}<br>
+  template <class InitTy><br>
+  StringMapEntry(unsigned strLen, InitTy &&V)<br>
+      : StringMapEntryBase(strLen), second(std::forward<InitTy>(V)) {}<br>
<br>
   StringRef getKey() const {<br>
     return StringRef(getKeyData(), getKeyLength());<br>
@@ -138,10 +139,9 @@ public:<br>
<br>
   /// Create - Create a StringMapEntry for the specified key and default<br>
   /// construct the value.<br>
-  template<typename AllocatorTy, typename InitType><br>
-  static StringMapEntry *Create(StringRef Key,<br>
-                                AllocatorTy &Allocator,<br>
-                                InitType InitVal) {<br>
+  template <typename AllocatorTy, typename InitType><br>
+  static StringMapEntry *Create(StringRef Key, AllocatorTy &Allocator,<br>
+                                InitType &&InitVal) {<br>
     unsigned KeyLength = Key.size();<br>
<br>
     // Allocate a new item with space for the string at the end and a null<br>
@@ -154,7 +154,7 @@ public:<br>
       static_cast<StringMapEntry*>(Allocator.Allocate(AllocSize,Alignment));<br>
<br>
     // Default construct the value.<br>
-    new (NewItem) StringMapEntry(KeyLength, std::move(InitVal));<br>
+    new (NewItem) StringMapEntry(KeyLength, std::forward<InitType>(InitVal));<br>
<br>
     // Copy the string information.<br>
     char *StrBuffer = const_cast<char*>(NewItem->getKeyData());<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>