OSDN Git Service

Add an operator+= for appending StringRefs onto std::strings.
authorJohn McCall <rjmccall@apple.com>
Fri, 13 May 2011 23:58:45 +0000 (23:58 +0000)
committerJohn McCall <rjmccall@apple.com>
Fri, 13 May 2011 23:58:45 +0000 (23:58 +0000)
Previously this pattern would be compiled using an implicit conversion
to std::string.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131325 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/StringRef.h

index 1766d2b..dcc6aa2 100644 (file)
@@ -447,6 +447,10 @@ namespace llvm {
     return LHS.compare(RHS) != -1;
   }
 
+  inline std::string &operator+=(std::string &buffer, llvm::StringRef string) {
+    return buffer.append(string.data(), string.size());
+  }
+
   /// @}
 
   // StringRefs can be treated like a POD type.