Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <boost/type_traits/is_base_of.hpp>
- // Must be parent for all classes
- class Object
- {
- };
- #define DECLARE_TYPE_BASE(T) \
- public: \
- typedef T ThisType;
- #define DECLARE_TYPE_INHERITANCE(T, BASE) \
- BOOST_STATIC_ASSERT((boost::is_base_of<Object, BASE>::value) == true); \
- DECLARE_TYPE_BASE(T) \
- public: \
- typedef BASE InheritedType;
- #define DECLARE_TYPE(T, BASE) \
- DECLARE_TYPE_INHERITANCE(T, BASE)
- class Bar : public Object
- {
- };
- class Foo : public Bar
- {
- DECLARE_TYPE(Foo, Bar)
- public:
- Foo() {}
- virtual ~Foo() {}
- };
Advertisement
Add Comment
Please, Sign In to add comment