SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
c++11.h
Go to the documentation of this file.
1
// -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
2
// vim:tabstop=4:shiftwidth=4:expandtab:
3
4
/*
5
* Copyright (C) 2013 Wu Yongwei <adah at users dot sourceforge dot net>
6
*
7
* This software is provided 'as-is', without any express or implied
8
* warranty. In no event will the authors be held liable for any
9
* damages arising from the use of this software.
10
*
11
* Permission is granted to anyone to use this software for any purpose,
12
* including commercial applications, and to alter it and redistribute
13
* it freely, subject to the following restrictions:
14
*
15
* 1. The origin of this software must not be misrepresented; you must
16
* not claim that you wrote the original software. If you use this
17
* software in a product, an acknowledgement in the product
18
* documentation would be appreciated but is not required.
19
* 2. Altered source versions must be plainly marked as such, and must
20
* not be misrepresented as being the original software.
21
* 3. This notice may not be removed or altered from any source
22
* distribution.
23
*
24
* This file is part of Stones of Nvwa:
25
* http://sourceforge.net/projects/nvwa
26
*
27
*/
28
37
#ifndef NVWA_CXX11_H
38
#define NVWA_CXX11_H
39
40
// Only Clang provides these macros; they need to be defined as follows
41
// to get a valid expression in preprocessing by other compilers.
42
#ifndef __has_extension
43
#define __has_extension(x) 0
44
#endif
45
#ifndef __has_feature
46
#define __has_feature(x) 0
47
#endif
48
#ifndef __has_include
49
#define __has_include(x) 0
50
#endif
51
52
// Detect whether C++11 mode is on (for GCC and Clang). MSVC does not
53
// have a special C++11 mode, so it is always on for Visual C++ 2010 and
54
// later.
55
#if __cplusplus >= 201103L || \
56
defined(__GXX_EXPERIMENTAL_CXX0X__) || \
57
(defined(_MSC_VER) && _MSC_VER >= 1600)
58
#define NVWA_CXX11_MODE 1
59
#else
60
#define NVWA_CXX11_MODE 0
61
#endif
62
63
64
/* Feature checks */
65
66
#if !defined(HAVE_CXX11_ATOMIC)
67
#if NVWA_CXX11_MODE && \
68
(__has_include(<atomic>) || \
69
(defined(_MSC_VER) && _MSC_VER >= 1700) || \
70
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 405 && \
71
!defined(__MINGW32__)))
72
// Note: MinGW GCC does not support atomics out of the box as of 4.8.
73
#define HAVE_CXX11_ATOMIC 1
74
#else
75
#define HAVE_CXX11_ATOMIC 0
76
#endif
77
#endif
78
79
#if !defined(HAVE_CXX11_AUTO_TYPE)
80
#if NVWA_CXX11_MODE && \
81
(__has_feature(cxx_auto_type) || \
82
(defined(_MSC_VER) && _MSC_VER >= 1600) || \
83
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 404))
84
#define HAVE_CXX11_AUTO_TYPE 1
85
#else
86
#define HAVE_CXX11_AUTO_TYPE 0
87
#endif
88
#endif
89
90
#if !defined(HAVE_CXX11_EXPLICIT_CONVERSION)
91
#if NVWA_CXX11_MODE && \
92
(__has_feature(cxx_explicit_conversions) || \
93
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 405))
94
#define HAVE_CXX11_EXPLICIT_CONVERSION 1
95
#else
96
#define HAVE_CXX11_EXPLICIT_CONVERSION 0
97
#endif
98
#endif
99
100
#if !defined(HAVE_CXX11_FINAL)
101
#if NVWA_CXX11_MODE && \
102
(__has_feature(cxx_override_control) || \
103
(defined(_MSC_VER) && _MSC_VER >= 1700) || \
104
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 407))
105
#define HAVE_CXX11_FINAL 1
106
#else
107
#define HAVE_CXX11_FINAL 0
108
#endif
109
#endif
110
111
#if !defined(HAVE_CXX11_FUTURE)
112
#if NVWA_CXX11_MODE && \
113
(__has_include(<future>) || \
114
(defined(_MSC_VER) && _MSC_VER >= 1700) || \
115
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 405 && \
116
!defined(__MINGW32__)))
117
// Note: MinGW GCC does not support futures out of the box as of 4.8.
118
#define HAVE_CXX11_FUTURE 1
119
#else
120
#define HAVE_CXX11_FUTURE 0
121
#endif
122
#endif
123
124
#if !defined(HAVE_CXX11_GENERALIZED_INITIALIZER)
125
#if NVWA_CXX11_MODE && \
126
(__has_feature(cxx_generalized_initializers) || \
127
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 404))
128
#define HAVE_CXX11_GENERALIZED_INITIALIZER 1
129
#else
130
#define HAVE_CXX11_GENERALIZED_INITIALIZER 0
131
#endif
132
#endif
133
134
#if !defined(HAVE_CXX11_LAMBDA)
135
#if NVWA_CXX11_MODE && \
136
(__has_feature(cxx_lambdas) || \
137
(defined(_MSC_VER) && _MSC_VER >= 1600) || \
138
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 405))
139
#define HAVE_CXX11_LAMBDA 1
140
#else
141
#define HAVE_CXX11_LAMBDA 0
142
#endif
143
#endif
144
145
#if !defined(HAVE_CXX11_MUTEX)
146
#if NVWA_CXX11_MODE && \
147
(__has_include(<mutex>) || \
148
(defined(_MSC_VER) && _MSC_VER >= 1700) || \
149
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 403 && \
150
!defined(__MINGW32__)))
151
// Note: MinGW GCC does not support std::mutex out of the box as of 4.8.
152
#define HAVE_CXX11_MUTEX 1
153
#else
154
#define HAVE_CXX11_MUTEX 0
155
#endif
156
#endif
157
158
#if !defined(HAVE_CXX11_NOEXCEPT)
159
#if NVWA_CXX11_MODE && \
160
(__has_feature(cxx_noexcept) || \
161
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 406))
162
#define HAVE_CXX11_NOEXCEPT 1
163
#else
164
#define HAVE_CXX11_NOEXCEPT 0
165
#endif
166
#endif
167
168
#if !defined(HAVE_CXX11_NULLPTR)
169
#if NVWA_CXX11_MODE && \
170
(__has_feature(cxx_nullptr) || \
171
(defined(_MSC_VER) && _MSC_VER >= 1600) || \
172
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 406))
173
#define HAVE_CXX11_NULLPTR 1
174
#else
175
#define HAVE_CXX11_NULLPTR 0
176
#endif
177
#endif
178
179
#if !defined(HAVE_CXX11_OVERRIDE)
180
#if NVWA_CXX11_MODE && \
181
(__has_feature(cxx_override_control) || \
182
(defined(_MSC_VER) && _MSC_VER >= 1600) || \
183
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 407))
184
#define HAVE_CXX11_OVERRIDE 1
185
#else
186
#define HAVE_CXX11_OVERRIDE 0
187
#endif
188
#endif
189
190
#if !defined(HAVE_CXX11_RANGE_FOR)
191
#if NVWA_CXX11_MODE && \
192
(__has_feature(cxx_range_for) || \
193
(defined(_MSC_VER) && _MSC_VER >= 1700) || \
194
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 406))
195
#define HAVE_CXX11_RANGE_FOR 1
196
#else
197
#define HAVE_CXX11_RANGE_FOR 0
198
#endif
199
#endif
200
201
#if !defined(HAVE_CXX11_RVALUE_REFERENCE)
202
#if NVWA_CXX11_MODE && \
203
(__has_feature(cxx_rvalue_references) || \
204
(defined(_MSC_VER) && _MSC_VER >= 1600) || \
205
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 405))
206
#define HAVE_CXX11_RVALUE_REFERENCE 1
207
#else
208
#define HAVE_CXX11_RVALUE_REFERENCE 0
209
#endif
210
#endif
211
212
#if !defined(HAVE_CXX11_STATIC_ASSERT)
213
#if NVWA_CXX11_MODE && \
214
(__has_feature(cxx_static_assert) || \
215
(defined(_MSC_VER) && _MSC_VER >= 1600) || \
216
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 403))
217
#define HAVE_CXX11_STATIC_ASSERT 1
218
#else
219
#define HAVE_CXX11_STATIC_ASSERT 0
220
#endif
221
#endif
222
223
#if !defined(HAVE_CXX11_THREAD)
224
#if NVWA_CXX11_MODE && \
225
(__has_include(<thread>) || \
226
(defined(_MSC_VER) && _MSC_VER >= 1700) || \
227
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 404 && \
228
!defined(__MINGW32__)))
229
// Note: MinGW GCC does not support std::thread out of the box as of 4.8.
230
#define HAVE_CXX11_THREAD 1
231
#else
232
#define HAVE_CXX11_THREAD 0
233
#endif
234
#endif
235
236
#if !defined(HAVE_CXX11_THREAD_LOCAL)
237
#if NVWA_CXX11_MODE && \
238
(__has_feature(cxx_thread_local) || \
239
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 408))
240
#define HAVE_CXX11_THREAD_LOCAL 1
241
#else
242
#define HAVE_CXX11_THREAD_LOCAL 0
243
#endif
244
#endif
245
246
#if !defined(HAVE_CXX11_TYPE_TRAITS)
247
#if NVWA_CXX11_MODE && \
248
(__has_include(<type_traits>) || \
249
(defined(_MSC_VER) && _MSC_VER >= 1600) || \
250
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 403))
251
#define HAVE_CXX11_TYPE_TRAITS 1
252
#else
253
#define HAVE_CXX11_TYPE_TRAITS 0
254
#endif
255
#endif
256
257
#if !defined(HAVE_CXX11_UNICODE_LITERAL)
258
#if NVWA_CXX11_MODE && \
259
(__has_feature(cxx_unicode_literals) || \
260
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 405))
261
#define HAVE_CXX11_UNICODE_LITERAL 1
262
#else
263
#define HAVE_CXX11_UNICODE_LITERAL 0
264
#endif
265
#endif
266
267
268
/* Workarounds */
269
270
#if HAVE_CXX11_FINAL
271
#define _FINAL final
272
#else
273
#define _FINAL
274
#endif
275
276
#if HAVE_CXX11_OVERRIDE
277
#define _OVERRIDE override
278
#else
279
#define _OVERRIDE
280
#endif
281
282
#if HAVE_CXX11_NOEXCEPT
283
#define _NOEXCEPT noexcept
284
#define _NOEXCEPT_(x) noexcept(x)
285
#else
286
#define _NOEXCEPT throw ()
287
#define _NOEXCEPT_(x)
288
#endif
289
290
#if HAVE_CXX11_NULLPTR
291
#define _NULLPTR nullptr
292
#else
293
#define _NULLPTR NULL
294
#endif
295
296
#if HAVE_CXX11_THREAD_LOCAL
297
#define _THREAD_LOCAL thread_local
298
#else
299
#ifdef _MSC_VER
300
#define _THREAD_LOCAL __declspec(thread)
301
#else
302
#define _THREAD_LOCAL __thread
303
#endif
304
#endif
305
306
#endif // NVWA_CXX11_H
src
foreign
nvwa
c++11.h
Generated on Sat Mar 18 2017 00:11:29 for SUMO - Simulation of Urban MObility by
1.8.11