diff options
author | Chris Lattner <sabre@nondot.org> | 2011-12-06 02:00:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-12-06 02:00:33 +0000 |
commit | 266451dd95b12323fad9418df9b217918ec7e9e0 (patch) | |
tree | 756814abbcb9ec6b2719264528ccf524ee1e694c /include/llvm/ADT | |
parent | bae56b4c216ac8b4573fb90e7d1a63acace6f53d (diff) | |
download | external_llvm-266451dd95b12323fad9418df9b217918ec7e9e0.zip external_llvm-266451dd95b12323fad9418df9b217918ec7e9e0.tar.gz external_llvm-266451dd95b12323fad9418df9b217918ec7e9e0.tar.bz2 |
allow TinyPtrVector to implicitly convert to ArrayRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145898 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT')
-rw-r--r-- | include/llvm/ADT/TinyPtrVector.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/llvm/ADT/TinyPtrVector.h b/include/llvm/ADT/TinyPtrVector.h index ee86d8b..e27dd4b 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<EltTy>() const { + if (Val.isNull()) + return ArrayRef<EltTy>(); + if (Val.template is<EltTy>()) + return *Val.template getAddrOf<EltTy>(); + return *Val.template get<VecTy*>(); + } + bool empty() const { // This vector can be empty if it contains no element, or if it // contains a pointer to an empty vector. |