Allow SmallString to implicitly convert to StringRef.
authorDaniel Dunbar <daniel@zuster.org>
Sat, 21 Nov 2009 02:01:24 +0000 (02:01 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 21 Nov 2009 02:01:24 +0000 (02:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89529 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/SmallString.h

index 035462515a83e96d1a1e5be3edb89ff80fc0e7a6..05bd8a42c67f650c967e3212298deb3dda111b9a 100644 (file)
@@ -38,12 +38,15 @@ public:
   // Extra methods.
   StringRef str() const { return StringRef(this->begin(), this->size()); }
 
+  // Implicit conversion to StringRef.
+  operator StringRef() const { return str(); }
+
   const char *c_str() {
     this->push_back(0);
     this->pop_back();
     return this->data();
   }
-  
+
   // Extra operators.
   const SmallString &operator=(StringRef RHS) {
     this->clear();