I am creating my own RTTI system for my event system. Below is the class EventTypeInfo. As you can see, this is not possible, just like std::type_info.
class EventTypeInfo
{
public:
EventTypeInfo(const EventTypeInfo&) = delete;
EventTypeInfo& operator=(const EventTypeInfo&) = delete;
inline bool operator==(const EventTypeInfo& other) const {
return this == &other;
}
};
The way to create these objects for each class of events is as follows:
template<class EventClass>
const EventTypeInfo& event::type::info()
{
static EventTypeInfo typeinfo;
return typeinfo;
}
Given that (1) these objects are created statically (which means that they will last for the entire duration of the application), (2) they cannot be copied, and (3) there is no way to change the fields EventTypeInfowithout resorting to const_cast, is it enough for me to implement operator==- this terms this == &other, or am I missing something?
source
share