throwing_ptr
Smart pointers that throw on dereference if null
compiler_checks.hpp
Go to the documentation of this file.
1 // Copyright Claudio Bantaloukas 2017-2018.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 
6 /** \file throwing/private/compiler_checks.hpp
7  * \brief Implementation details
8  * This header file must not be included directly
9  * and definitions herein may change without notice
10  */
11 
12 
13 #if (defined(_MSC_VER) && _MSC_VER < 1800) ||
14  (!defined(_MSC_VER) && __cplusplus < 201103L)
15 #error throwing_ptr requires at least C++11
16 #endif
17 
18 #if defined(__clang__)
19 // clang supports from 3.1 on
20 #define TSP_CONSTEXPR constexpr
21 #define TSP_NOEXCEPT noexcept
22 
23 #if defined(__cpp_lib_shared_ptr_arrays) && __cpp_lib_shared_ptr_arrays
24 #define TSP_ARRAY_SUPPORT 1
25 #else
26 #define TSP_ARRAY_SUPPORT 0
27 #endif
28 
29 #elif defined(_MSC_VER)
30 
31 #if _MSC_VER >= 1912
32 // Visual Studio 2017 15.5
33 #define TSP_CONSTEXPR constexpr
34 #define TSP_NOEXCEPT noexcept
35 #define TSP_ARRAY_SUPPORT 1
36 #elif _MSC_VER >= 1910
37 // Visual Studio 2017 15.0
38 #define TSP_CONSTEXPR constexpr
39 #define TSP_NOEXCEPT noexcept
40 #define TSP_ARRAY_SUPPORT 0
41 #elif _MSC_VER >= 1900
42 // Visual Studio 2015 14.0
43 #define TSP_CONSTEXPR constexpr
44 #define TSP_NOEXCEPT noexcept
45 #define TSP_ARRAY_SUPPORT 0
46 #elif _MSC_VER >= 1800
47 // Visual Studio 2013
48 #define TSP_CONSTEXPR
49 #define TSP_NOEXCEPT
50 #define TSP_ARRAY_SUPPORT 0
51 #endif
52 
53 #elif defined(__GNUC__)
54 
55 #if __cpp_constexpr >= 200704
56 #define TSP_CONSTEXPR constexpr
57 #else
58 #define TSP_CONSTEXPR
59 #endif
60 
61 #define TSP_NOEXCEPT noexcept
62 #if defined(__cpp_lib_shared_ptr_arrays) && __cpp_lib_shared_ptr_arrays
63 #define TSP_ARRAY_SUPPORT 1
64 #else
65 #define TSP_ARRAY_SUPPORT 0
66 #endif
67 
68 #else
69 // Unknown compiler, bare minimum
70 #define TSP_CONSTEXPR
71 #define TSP_NOEXCEPT
72 #define TSP_ARRAY_SUPPORT false
73 #endif