From 983c7fe847dd3f46945f0117ab19345b9c68e88f Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sat, 21 Nov 2009 02:01:24 +0000 Subject: [PATCH] Allow SmallString to implicitly convert to StringRef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89529 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/SmallString.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/llvm/ADT/SmallString.h b/include/llvm/ADT/SmallString.h index 035462515a8..05bd8a42c67 100644 --- a/include/llvm/ADT/SmallString.h +++ b/include/llvm/ADT/SmallString.h @@ -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();