-
Notifications
You must be signed in to change notification settings - Fork 9
/
globaldef.h
220 lines (150 loc) · 4.24 KB
/
globaldef.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#ifndef YAYA_GLOBALDEF_H_
#define YAYA_GLOBALDEF_H_
#ifdef __cplusplus
#include <cwchar>
#include <string>
#include <map>
#include <memory>
#endif
//=============================================================================================================
// compiler compat section
//=============================================================================================================
#ifndef _MSVC_LANG
//C++11 or older
#if __cplusplus >= 201103L
#include <memory>
#define std_shared_ptr std::shared_ptr
#define std_make_shared std::make_shared
// freebsdでdefine nullptr 0を行うと
// aya5.cpp:L507のloghandler_list.emplace_back(nullptr)で
// 型不一致のエラーが出るのでdefineしない。
#else
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#define std_shared_ptr boost::shared_ptr
#define std_make_shared boost::make_shared
#define nullptr 0
#endif // C++11
#else
#define std_shared_ptr std::shared_ptr
#define std_make_shared std::make_shared
#endif //_MSVC_LANG
#define AYX_WIN64_AWARE
#ifdef _MSVC_LANG
# define CPP_STD_VER (_MSVC_LANG/100)
#else
# ifdef _MSC_VER
# if _MSC_VER > 1600
# define CPP_STD_VER 2011
# else
# define CPP_STD_VER 1998
# endif
# else
# define CPP_STD_VER 2020
# endif
#endif
#ifdef _MSC_VER
#pragma warning (disable: 4786)
#pragma warning (disable: 4819)
#pragma warning (3: 4032 4057 4092)
#pragma warning (3: 4115 4121 4125 4130 4132 4134 4152 4189)
#pragma warning (3: 4207 4208 4209 4211 4212 4220 4223 4234 4238)
#pragma warning (3: 4355 4504 4505 4515)
//#pragma warning (3: 4663 4665 4670 4671 4672 4673 4674)
#pragma warning (3: 4665 4670 4671 4672 4673 4674)
//#pragma warning (3: 4701 4702 4705 4706 4709 4727)
#pragma warning (3: 4701 4705 4706 4709 4727)
#if _MSC_VER >= 1300
#undef AYX_WIN64_AWARE
#define AYX_WIN64_AWARE __w64
#endif
#if _MSC_VER <= 1200
#define for if(0);else for
#ifdef __cplusplus
namespace std {
#endif
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#ifdef __cplusplus
};
#endif
#define INT64_IS_NOT_STD
#ifndef LLONG_MIN
#define LLONG_MIN _I64_MIN
#endif
#ifndef LLONG_MAX
#define LLONG_MAX _I64_MAX
#endif
#ifndef ULLONG_MAX
#define ULLONG_MAX _UI64_MAX
#endif
#define ULL_DEF(p) p ## Ui64
#define LL_DEF(p) p ## i64
#else
#include <cstdint>
#ifndef __cplusplus
typedef long long int64_t;
typedef unsigned long long uint64_t;
#endif
#define ULL_DEF(p) p ## ULL
#define LL_DEF(p) p ## LL
#endif //1200
#endif //MSC_VER
#ifndef _WINDOWS
#define ULL_DEF(p) p
#define LL_DEF(p) p
#endif // _WINDOWS
#if CPP_STD_VER < 2011
//C++11 or older
#define constexpr const
#define emplace_back(p) push_back(p)
#define _Pre_notnull_
#define _Always_(p)
#define _Printf_format_string_
#define LVALUE_MODIFIER
#define std_move(d) (d)
#else
#define std_move(d) std::move(d)
#define LVALUE_MODIFIER &
#endif //CPP_STD_VER
//=============================================================================================================
// yaya type section
//=============================================================================================================
#ifdef __cplusplus
namespace yaya {
#if CPP_STD_VER >= 2011
struct memory_error:std::exception{
virtual const char*what()const noexcept{
return "memory error";
}
};
#else
struct memory_error:std::exception{
virtual const char*what()const{
return "memory error";
}
};
#endif
typedef wchar_t char_t;
typedef std::basic_string<char_t> string_t;
typedef std::int64_t int_t;
typedef std::int64_t time_t;
typedef std_shared_ptr<string_t> share_string_t;
typedef std_shared_ptr<const string_t> const_share_string_t;
typedef std::map<yaya::string_t,size_t> indexmap;
template<class T> void shared_ptr_deep_copy(const std_shared_ptr<T> &from,std_shared_ptr<T> &to) {
if( from.get() ) {
to = std_make_shared<T>(*from);
}
else {
to.reset();
}
}
#ifdef _WIN64
typedef std::int64_t native_signed;
#else
typedef int AYX_WIN64_AWARE native_signed;
#endif
}; // namespace yaya {
#endif //__cplusplus
#endif // YAYA_GLOBALDEF_H_