[PATCH] D73640: [SmallString] Add explicit conversion to std::string

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 29 13:59:17 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd88a5c398776: [SmallString] Remove StringRef indirection for std::string conversion. (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D73640?vs=241213&id=241286#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73640/new/

https://reviews.llvm.org/D73640

Files:
  llvm/include/llvm/ADT/SmallString.h


Index: llvm/include/llvm/ADT/SmallString.h
===================================================================
--- llvm/include/llvm/ADT/SmallString.h
+++ llvm/include/llvm/ADT/SmallString.h
@@ -275,7 +275,9 @@
   /// Implicit conversion to StringRef.
   operator StringRef() const { return str(); }
 
-  explicit operator std::string() const { return str().str(); }
+  explicit operator std::string() const {
+    return std::string(this->begin(), this->size());
+  }
 
   // Extra operators.
   const SmallString &operator=(StringRef RHS) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73640.241286.patch
Type: text/x-patch
Size: 543 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200129/58a8f72e/attachment.bin>


More information about the llvm-commits mailing list