-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNMF_RTTI.h
43 lines (35 loc) · 1.27 KB
/
NMF_RTTI.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once
#include <typeinfo>
#include <rttidata.h>
#ifndef NMF_VERSION
#include "NMF.h"
#endif
namespace NMF
{
class RTTI
{
public:
static const std::type_info* TypeId(void* inptr)
{
return reinterpret_cast<const std::type_info*>(__RTtypeid(inptr));
}
template<typename TO, typename FROM>
static TO DynamicCast(FROM inptr)
{
static_assert(std::is_pointer_v<FROM>, "Only pointers are supported!");
static_assert(std::is_pointer_v<TO>, "Only pointers are supported!");
return static_cast<TO>(__RTDynamicCast(inptr, 0, std::remove_pointer_t<FROM>::TypeDescriptor, std::remove_pointer_t<TO>::TypeDescriptor, 0));
}
};
/*inline const std::type_info* RTTI::TypeId(void* inptr)
{
return reinterpret_cast<const std::type_info*>(__RTtypeid(inptr));
}
template<typename TO, typename FROM>
inline TO RTTI::DynamicCast(FROM inptr)
{
static_assert(std::is_pointer_v<FROM>, "Only pointers are supported!");
static_assert(std::is_pointer_v<TO>, "Only pointers are supported!");
return static_cast<TO>(__RTDynamicCast(inptr, 0, std::remove_pointer_t<FROM>::TypeDescriptor, std::remove_pointer_t<TO>::TypeDescriptor, 0));
}*/
}