diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-03-30 18:05:52 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-03-30 18:05:52 +0000 |
commit | 0179e977234fef45b1877eb93a3c7565cdd1862d (patch) | |
tree | d4e9f8ead35ae48243eb766183aa3b6602585b3d /include/llvm/Support/Casting.h | |
parent | 7a8cf2822de1c69551588fc4395bdd0fec18611f (diff) | |
download | llvm-0179e977234fef45b1877eb93a3c7565cdd1862d.tar.gz llvm-0179e977234fef45b1877eb93a3c7565cdd1862d.tar.bz2 llvm-0179e977234fef45b1877eb93a3c7565cdd1862d.tar.xz |
Switch isa_impl from a function template to a class template with a
static inline member function doit(). This enables the use of partial
specialization to override the last stage of the "isa" check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99898 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/Casting.h')
-rw-r--r-- | include/llvm/Support/Casting.h | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/include/llvm/Support/Casting.h b/include/llvm/Support/Casting.h index 17bcb59905..dccbfadfa3 100644 --- a/include/llvm/Support/Casting.h +++ b/include/llvm/Support/Casting.h @@ -50,9 +50,11 @@ template<typename From> struct simplify_type<const From> { // if (isa<Type*>(myVal)) { ... } // template <typename To, typename From> -inline bool isa_impl(const From &Val) { - return To::classof(&Val); -} +struct isa_impl { + static inline bool doit(const From &Val) { + return To::classof(&Val); + } +}; template<typename To, typename From, typename SimpleType> struct isa_impl_wrap { @@ -68,7 +70,7 @@ template<typename To, typename FromTy> struct isa_impl_wrap<To, const FromTy, const FromTy> { // When From == SimpleType, we are as simple as we are going to get. static bool doit(const FromTy &Val) { - return isa_impl<To,FromTy>(Val); + return isa_impl<To,FromTy>::doit(Val); } }; @@ -251,10 +253,12 @@ struct foo { }*/ }; -template <> inline bool isa_impl<foo,bar>(const bar &Val) { - dbgs() << "Classof: " << &Val << "\n"; - return true; -} +template <> struct isa_impl<foo,bar> { + static inline bool doit(const bar &Val) { + dbgs() << "Classof: " << &Val << "\n"; + return true; + } +}; bar *fub(); |