From 6765f78efbd9d43f429344af7d997ec2df495b02 Mon Sep 17 00:00:00 2001 From: John McCall Date: Fri, 13 May 2011 23:58:45 +0000 Subject: [PATCH] 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 --- include/llvm/ADT/StringRef.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index 1766d2b9f2d..dcc6aa2897c 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.