[llvm-commits] [llvm] r131325 - /llvm/trunk/include/llvm/ADT/StringRef.h
John McCall
rjmccall at apple.com
Fri May 13 16:58:45 PDT 2011
Author: rjmccall
Date: Fri May 13 18:58:45 2011
New Revision: 131325
URL: http://llvm.org/viewvc/llvm-project?rev=131325&view=rev
Log:
Add an operator+= for appending StringRefs onto std::strings.
Previously this pattern would be compiled using an implicit conversion
to std::string.
Modified:
llvm/trunk/include/llvm/ADT/StringRef.h
Modified: llvm/trunk/include/llvm/ADT/StringRef.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=131325&r1=131324&r2=131325&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringRef.h (original)
+++ llvm/trunk/include/llvm/ADT/StringRef.h Fri May 13 18:58:45 2011
@@ -447,6 +447,10 @@
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.
More information about the llvm-commits
mailing list