Lodestone.Common
Loading...
Searching...
No Matches
IHasDerivedTypes.h
Go to the documentation of this file.
1
8#ifndef LODESTONE_IHASDERIVEDTYPES_H
9#define LODESTONE_IHASDERIVEDTYPES_H
10
13 template <typename EType>
15 public:
16 constexpr IHasDerivedTypes() = default;
17 constexpr virtual ~IHasDerivedTypes() = default;
18
19 // TODO theoretically we can avoid the vcall if we store type as const in here?
20 virtual constexpr EType type() = 0;
21
22 bool constexpr instanceOf(EType type) {
23 return this->type() == type;
24 }
25
26 bool constexpr instanceOf(const IHasDerivedTypes *inst) {
27 return this->type() == inst->type();
28 }
29
30 bool constexpr instanceOf(const IHasDerivedTypes &inst) {
31 return this->type() == inst.type();
32 }
33 };
34}
35
36#endif // LODESTONE_IHASDERIVEDTYPES_H
virtual constexpr EType type()=0
bool constexpr instanceOf(const IHasDerivedTypes &inst)
Definition IHasDerivedTypes.h:30
virtual constexpr ~IHasDerivedTypes()=default
bool constexpr instanceOf(const IHasDerivedTypes *inst)
Definition IHasDerivedTypes.h:26
bool constexpr instanceOf(EType type)
Definition IHasDerivedTypes.h:22
Definition Casts.cpp:10