blob: 193dc948fd0c7dc29ccae3a5f647bcd2ebb60f41 (
plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#ifndef SLANG_CORE_TYPE_TRAITS_H
#define SLANG_CORE_TYPE_TRAITS_H
namespace Slang
{
struct TraitResultYes
{
char x;
};
struct TraitResultNo
{
char x[2];
};
template<typename B, typename D>
struct IsBaseOfTraitHost
{
operator B*() const { return nullptr; }
operator D*() { return nullptr; }
};
template<typename B, typename D>
struct IsBaseOf
{
template<typename T>
static TraitResultYes Check(D*, T)
{
return TraitResultYes();
}
static TraitResultNo Check(B*, int) { return TraitResultNo(); }
enum
{
Value = sizeof(Check(IsBaseOfTraitHost<B, D>(), int())) == sizeof(TraitResultYes)
};
};
template<bool B, class T = void>
struct EnableIf
{
};
template<class T>
struct EnableIf<true, T>
{
typedef T type;
};
template<typename B, typename D>
struct IsConvertible
{
static TraitResultYes Use(B) { return TraitResultYes(); };
static TraitResultNo Use(...) { return TraitResultNo(); };
enum
{
Value = sizeof(Use(*(D*)(nullptr))) == sizeof(TraitResultYes)
};
};
} // namespace Slang
#endif
|