aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/ADT/StringRef.h
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-05-13 23:58:45 +0000
committerJohn McCall <rjmccall@apple.com>2011-05-13 23:58:45 +0000
commit6765f78efbd9d43f429344af7d997ec2df495b02 (patch)
treea90d42f422e1f35380d8cb86a96a1c304a304e08 /include/llvm/ADT/StringRef.h
parent1c3c8ea66261b7a4fd8813f096514c0a041fbda6 (diff)
Add an operator+= for appending StringRefs onto std::strings.
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
Diffstat (limited to 'include/llvm/ADT/StringRef.h')
-rw-r--r--include/llvm/ADT/StringRef.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h
index 1766d2b9f2..dcc6aa2897 100644
--- a/include/llvm/ADT/StringRef.h
+++ b/include/llvm/ADT/StringRef.h
@@ -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.