Add a castAs<U> accessor to CanQual<T>.

llvm-svn: 150786
This commit is contained in:
John McCall 2012-02-17 03:32:17 +00:00
parent 400d1f44d1
commit 1e25a97ae2
1 changed files with 9 additions and 0 deletions

View File

@ -108,6 +108,8 @@ public:
/// or a derived class thereof, a NULL canonical type.
template<typename U> CanProxy<U> getAs() const;
template<typename U> CanProxy<U> castAs() const;
/// \brief Overloaded arrow operator that produces a canonical type
/// proxy.
CanProxy<T> operator->() const;
@ -752,6 +754,13 @@ CanProxy<U> CanQual<T>::getAs() const {
return CanProxy<U>();
}
template<typename T>
template<typename U>
CanProxy<U> CanQual<T>::castAs() const {
assert(!Stored.isNull() && isa<U>(Stored.getTypePtr()));
return CanQual<U>::CreateUnsafe(Stored);
}
template<typename T>
CanProxy<T> CanQual<T>::operator->() const {
return CanProxy<T>(*this);