|
1
|
1 #pragma once
|
|
|
2
|
|
|
3 namespace pfc {
|
|
|
4
|
|
|
5 class traits_default {
|
|
|
6 public:
|
|
|
7 enum {
|
|
|
8 realloc_safe = false,
|
|
|
9 needs_destructor = true,
|
|
|
10 needs_constructor = true,
|
|
|
11 constructor_may_fail = true
|
|
|
12 };
|
|
|
13 };
|
|
|
14
|
|
|
15 class traits_default_movable {
|
|
|
16 public:
|
|
|
17 enum {
|
|
|
18 realloc_safe = true,
|
|
|
19 needs_destructor = true,
|
|
|
20 needs_constructor = true,
|
|
|
21 constructor_may_fail = true
|
|
|
22 };
|
|
|
23 };
|
|
|
24
|
|
|
25 class traits_rawobject : public traits_default {
|
|
|
26 public:
|
|
|
27 enum {
|
|
|
28 realloc_safe = true,
|
|
|
29 needs_destructor = false,
|
|
|
30 needs_constructor = false,
|
|
|
31 constructor_may_fail = false
|
|
|
32 };
|
|
|
33 };
|
|
|
34
|
|
|
35 class traits_vtable {
|
|
|
36 public:
|
|
|
37 enum {
|
|
|
38 realloc_safe = true,
|
|
|
39 needs_destructor = true,
|
|
|
40 needs_constructor = true,
|
|
|
41 constructor_may_fail = false
|
|
|
42 };
|
|
|
43 };
|
|
|
44
|
|
|
45 template<typename T> class traits_t : public traits_default {};
|
|
|
46
|
|
|
47 template<typename traits1,typename traits2>
|
|
|
48 class combine_traits {
|
|
|
49 public:
|
|
|
50 enum {
|
|
|
51 realloc_safe = (traits1::realloc_safe && traits2::realloc_safe),
|
|
|
52 needs_destructor = (traits1::needs_destructor || traits2::needs_destructor),
|
|
|
53 needs_constructor = (traits1::needs_constructor || traits2::needs_constructor),
|
|
|
54 constructor_may_fail = (traits1::constructor_may_fail || traits2::constructor_may_fail),
|
|
|
55 };
|
|
|
56 };
|
|
|
57
|
|
|
58 template<typename type1, typename type2>
|
|
|
59 class traits_combined : public combine_traits<traits_t<type1>,traits_t<type2> > {};
|
|
|
60
|
|
|
61 template<typename T> class traits_t<T*> : public traits_rawobject {};
|
|
|
62
|
|
|
63 template<> class traits_t<char> : public traits_rawobject {};
|
|
|
64 template<> class traits_t<unsigned char> : public traits_rawobject {};
|
|
|
65 template<> class traits_t<signed char> : public traits_rawobject {};
|
|
|
66 template<> class traits_t<wchar_t> : public traits_rawobject {};
|
|
|
67 template<> class traits_t<short> : public traits_rawobject {};
|
|
|
68 template<> class traits_t<unsigned short> : public traits_rawobject {};
|
|
|
69 template<> class traits_t<int> : public traits_rawobject {};
|
|
|
70 template<> class traits_t<unsigned int> : public traits_rawobject {};
|
|
|
71 template<> class traits_t<long> : public traits_rawobject {};
|
|
|
72 template<> class traits_t<unsigned long> : public traits_rawobject {};
|
|
|
73 template<> class traits_t<long long> : public traits_rawobject {};
|
|
|
74 template<> class traits_t<unsigned long long> : public traits_rawobject {};
|
|
|
75 template<> class traits_t<bool> : public traits_rawobject {};
|
|
|
76
|
|
|
77 template<> class traits_t<float> : public traits_rawobject {};
|
|
|
78 template<> class traits_t<double> : public traits_rawobject {};
|
|
|
79
|
|
|
80 template<> class traits_t<GUID> : public traits_rawobject {};
|
|
|
81
|
|
|
82 template<typename T,t_size p_count>
|
|
|
83 class traits_t<T[p_count]> : public traits_t<T> {};
|
|
|
84
|
|
|
85 }
|