From 266451dd95b12323fad9418df9b217918ec7e9e0 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 6 Dec 2011 02:00:33 +0000 Subject: [PATCH] allow TinyPtrVector to implicitly convert to ArrayRef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145898 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/TinyPtrVector.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/llvm/ADT/TinyPtrVector.h b/include/llvm/ADT/TinyPtrVector.h index ee86d8bdf70..e27dd4b7850 100644 --- a/include/llvm/ADT/TinyPtrVector.h +++ b/include/llvm/ADT/TinyPtrVector.h @@ -37,6 +37,15 @@ public: delete V; } + // implicit conversion operator to ArrayRef. + operator ArrayRef() const { + if (Val.isNull()) + return ArrayRef(); + if (Val.template is()) + return *Val.template getAddrOf(); + return *Val.template get(); + } + bool empty() const { // This vector can be empty if it contains no element, or if it // contains a pointer to an empty vector.