Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: is-a.h
- ===================================================================
- --- is-a.h (revision 217985)
- +++ is-a.h (working copy)
- @@ -147,10 +147,26 @@ struct is_a_helper
- {
- template <typename U>
- static inline bool test (U *p);
- + static inline bool test (T *) { return true; }
- template <typename U>
- static inline T cast (U *p);
- };
- +
- +template <typename T>
- +struct is_a_helper<const T*>
- +{
- + template <typename U>
- + static inline bool test (const U *p);
- + template <typename U>
- + static inline bool test (U *p) {return test(const_cast<const U*>(p));}
- + static inline bool test (const T *) { return true; }
- + template <typename U>
- + static inline const T *cast (const U *p);
- + template <typename U>
- + static inline const T *cast (U *p) { return cast(const_cast<const U*>(p)); }
- +};
- +
- /* Note that we deliberately do not define the 'test' member template. Not
- doing so will result in a build-time error for type relationships that have
- not been defined, rather than a run-time error. See the discussion above
- @@ -169,6 +185,15 @@ is_a_helper <T>::cast (U *p)
- }
- +template <typename T>
- +template <typename U>
- +inline const T*
- +is_a_helper <const T*>::cast (const U *p)
- +{
- + return reinterpret_cast <const T*> (p);
- +}
- +
- +
- /* The public interface. */
- /* A generic test for a type relationship. See the discussion above for when
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement