Skip to content

Commit dd5fc24

Browse files
committed
Handle presence of various C++11 type traits, take 2 (#58, thanks to @trapexit)
1 parent 7ea291a commit dd5fc24

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

include/nonstd/optional.hpp

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,28 @@ namespace nonstd {
293293
#define optional_CPP11_140 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1900)
294294
#define optional_CPP11_141 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1910)
295295

296-
#define optional_CPP11_140_490 ((optional_CPP11_OR_GREATER_ && optional_COMPILER_GNUC_VERSION >= 490) || (optional_COMPILER_MSVC_VER >= 1910))
297-
298296
#define optional_CPP14_000 (optional_CPP14_OR_GREATER)
299297
#define optional_CPP17_000 (optional_CPP17_OR_GREATER)
300298

299+
// gcc >= 4.9, msvc >= vc14.1 (vs17):
300+
#define optional_CPP11_140_G490 ((optional_CPP11_OR_GREATER_ && optional_COMPILER_GNUC_VERSION >= 490) || (optional_COMPILER_MSVC_VER >= 1910))
301+
302+
// clang >= 3.5, msvc >= vc11 (vs12):
303+
#define optional_CPP11_110_C350 ( optional_CPP11_110 && !optional_BETWEEN( optional_COMPILER_CLANG_VERSION, 1, 350 ) )
304+
305+
// clang >= 3.5, gcc >= 5.0, msvc >= vc11 (vs12):
306+
#define optional_CPP11_110_C350_G500 \
307+
( optional_CPP11_110 && \
308+
!( optional_BETWEEN( optional_COMPILER_CLANG_VERSION, 1, 350 ) \
309+
|| optional_BETWEEN( optional_COMPILER_GNUC_VERSION , 1, 500 ) ) )
310+
301311
// Presence of C++11 language features:
302312

303313
#define optional_HAVE_CONSTEXPR_11 optional_CPP11_140
304314
#define optional_HAVE_IS_DEFAULT optional_CPP11_140
305315
#define optional_HAVE_NOEXCEPT optional_CPP11_140
306316
#define optional_HAVE_NULLPTR optional_CPP11_100
307-
#define optional_HAVE_REF_QUALIFIER optional_CPP11_140_490
317+
#define optional_HAVE_REF_QUALIFIER optional_CPP11_140_G490
308318
#define optional_HAVE_INITIALIZER_LIST optional_CPP11_140
309319

310320
// Presence of C++14 language features:
@@ -324,19 +334,12 @@ namespace nonstd {
324334
#define optional_HAVE_TR1_TYPE_TRAITS (!! optional_COMPILER_GNUC_VERSION )
325335
#define optional_HAVE_TR1_ADD_POINTER (!! optional_COMPILER_GNUC_VERSION )
326336

327-
#define optional_HAVE_IS_ASSIGNABLE optional_CPP11_110
328-
#define optional_HAVE_IS_MOVE_CONSTRUCTIBLE optional_CPP11_110
329-
#define optional_HAVE_IS_NOTHROW_MOVE_ASSIGNABLE optional_CPP11_110
330-
#define optional_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE optional_CPP11_110
331-
332-
// clang < 3.5, gcc < 5.0, msvc < vc11 (vs12):
333-
#define optional_HAVE_TRIV_CPMV_CONSTRUCTABLE \
334-
( optional_CPP11_110 && \
335-
!( optional_BETWEEN( optional_COMPILER_CLANG_VERSION, 1, 350 ) \
336-
|| optional_BETWEEN( optional_COMPILER_GNUC_VERSION , 1, 500 ) ) )
337-
338-
#define optional_HAVE_IS_TRIVIALLY_COPY_CONSTRUCTIBLE optional_HAVE_TRIV_CPMV_CONSTRUCTABLE
339-
#define optional_HAVE_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE optional_HAVE_TRIV_CPMV_CONSTRUCTABLE
337+
#define optional_HAVE_IS_ASSIGNABLE optional_CPP11_110_C350
338+
#define optional_HAVE_IS_MOVE_CONSTRUCTIBLE optional_CPP11_110_C350
339+
#define optional_HAVE_IS_NOTHROW_MOVE_ASSIGNABLE optional_CPP11_110_C350
340+
#define optional_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE optional_CPP11_110_C350
341+
#define optional_HAVE_IS_TRIVIALLY_COPY_CONSTRUCTIBLE optional_CPP11_110_C350_G500
342+
#define optional_HAVE_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE optional_CPP11_110_C350_G500
340343

341344
// C++ feature usage:
342345

0 commit comments

Comments
 (0)