]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Defines configuration macros used throughout the library. | |
4 | ||
b32b8144 | 5 | @copyright Louis Dionne 2013-2017 |
7c673cae FG |
6 | Distributed under the Boost Software License, Version 1.0. |
7 | (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | |
8 | */ | |
9 | ||
10 | #ifndef BOOST_HANA_CONFIG_HPP | |
11 | #define BOOST_HANA_CONFIG_HPP | |
12 | ||
13 | #include <boost/hana/version.hpp> | |
14 | ||
15 | ||
16 | ////////////////////////////////////////////////////////////////////////////// | |
17 | // Detect the compiler | |
18 | ////////////////////////////////////////////////////////////////////////////// | |
19 | ||
20 | #if defined(_MSC_VER) && !defined(__clang__) // MSVC | |
21 | // This must be checked first, because otherwise it produces a fatal | |
22 | // error due to unrecognized #warning directives used below. | |
92f5a8d4 TL |
23 | |
24 | # if _MSC_VER < 1915 | |
25 | # pragma message("Warning: the native Microsoft compiler is not supported due to lack of proper C++14 support.") | |
26 | # else | |
27 | // 1. Active issues | |
28 | // Multiple copy/move ctors | |
29 | # define BOOST_HANA_WORKAROUND_MSVC_MULTIPLECTOR_106654 | |
30 | ||
31 | // 2. Issues fixed in the development branch of MSVC | |
32 | // Forward declaration of class template member function returning decltype(auto) | |
33 | # define BOOST_HANA_WORKAROUND_MSVC_DECLTYPEAUTO_RETURNTYPE_662735 | |
34 | ||
35 | // 3. Issues fixed conditionally | |
36 | // Requires __declspec(empty_bases) | |
37 | // Empty base optimization | |
38 | # define BOOST_HANA_WORKAROUND_MSVC_EMPTYBASE | |
39 | ||
40 | // Requires /experimental:preprocessor | |
41 | // Variadic macro expansion | |
42 | # if !defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL | |
43 | # define BOOST_HANA_WORKAROUND_MSVC_PREPROCESSOR_616033 | |
44 | # endif | |
45 | # endif | |
7c673cae FG |
46 | |
47 | #elif defined(__clang__) && defined(_MSC_VER) // Clang-cl (Clang for Windows) | |
48 | ||
49 | # define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION( \ | |
50 | __clang_major__, __clang_minor__, __clang_patchlevel__) | |
51 | ||
7c673cae FG |
52 | #elif defined(__clang__) && defined(__apple_build_version__) // Apple's Clang |
53 | ||
54 | # if __apple_build_version__ >= 6020049 | |
55 | # define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION(3, 6, 0) | |
7c673cae FG |
56 | # endif |
57 | ||
58 | #elif defined(__clang__) // genuine Clang | |
59 | ||
60 | # define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION( \ | |
61 | __clang_major__, __clang_minor__, __clang_patchlevel__) | |
62 | ||
7c673cae FG |
63 | #elif defined(__GNUC__) // GCC |
64 | ||
65 | # define BOOST_HANA_CONFIG_GCC BOOST_HANA_CONFIG_VERSION( \ | |
66 | __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) | |
67 | ||
7c673cae FG |
68 | #endif |
69 | ||
70 | ////////////////////////////////////////////////////////////////////////////// | |
71 | // Check the compiler for general C++14 capabilities | |
72 | ////////////////////////////////////////////////////////////////////////////// | |
73 | #if (__cplusplus < 201400) | |
74 | # if defined(_MSC_VER) | |
92f5a8d4 TL |
75 | # if _MSC_VER < 1915 |
76 | # pragma message("Warning: Your compiler doesn't provide C++14 or higher capabilities. Try adding the compiler flag '-std=c++14' or '-std=c++1y'.") | |
77 | # endif | |
7c673cae FG |
78 | # else |
79 | # warning "Your compiler doesn't provide C++14 or higher capabilities. Try adding the compiler flag '-std=c++14' or '-std=c++1y'." | |
80 | # endif | |
81 | #endif | |
82 | ||
7c673cae FG |
83 | ////////////////////////////////////////////////////////////////////////////// |
84 | // Caveats and other compiler-dependent options | |
85 | ////////////////////////////////////////////////////////////////////////////// | |
86 | ||
b32b8144 FG |
87 | // `BOOST_HANA_CONFIG_HAS_CONSTEXPR_LAMBDA` enables some constructs requiring |
88 | // `constexpr` lambdas, which are in the language starting with C++17. | |
7c673cae | 89 | // |
b32b8144 FG |
90 | // Always disabled for now because Clang only has partial support for them |
91 | // (captureless lambdas only). | |
92 | #if defined(__cplusplus) && __cplusplus > 201402L | |
93 | # define BOOST_HANA_CONSTEXPR_STATELESS_LAMBDA constexpr | |
94 | // # define BOOST_HANA_CONFIG_HAS_CONSTEXPR_LAMBDA | |
95 | #else | |
96 | # define BOOST_HANA_CONSTEXPR_STATELESS_LAMBDA /* nothing */ | |
97 | #endif | |
98 | ||
99 | // `BOOST_HANA_CONSTEXPR_LAMBDA` expands to `constexpr` if constexpr lambdas | |
7c673cae | 100 | // are supported and to nothing otherwise. |
b32b8144 | 101 | #if defined(BOOST_HANA_CONFIG_HAS_CONSTEXPR_LAMBDA) |
7c673cae FG |
102 | # define BOOST_HANA_CONSTEXPR_LAMBDA constexpr |
103 | #else | |
104 | # define BOOST_HANA_CONSTEXPR_LAMBDA /* nothing */ | |
105 | #endif | |
106 | ||
7c673cae FG |
107 | ////////////////////////////////////////////////////////////////////////////// |
108 | // Namespace macros | |
109 | ////////////////////////////////////////////////////////////////////////////// | |
110 | #define BOOST_HANA_NAMESPACE_BEGIN namespace boost { namespace hana { | |
111 | ||
112 | #define BOOST_HANA_NAMESPACE_END }} | |
113 | ||
114 | ////////////////////////////////////////////////////////////////////////////// | |
115 | // Library features and options that can be tweaked by users | |
116 | ////////////////////////////////////////////////////////////////////////////// | |
117 | ||
118 | #if defined(BOOST_HANA_DOXYGEN_INVOKED) || \ | |
119 | (defined(NDEBUG) && !defined(BOOST_HANA_CONFIG_DISABLE_ASSERTIONS)) | |
120 | //! @ingroup group-config | |
121 | //! Disables the `BOOST_HANA_*_ASSERT` macro & friends. | |
122 | //! | |
123 | //! When this macro is defined, the `BOOST_HANA_*_ASSERT` macro & friends | |
124 | //! are disabled, i.e. they expand to nothing. | |
125 | //! | |
126 | //! This macro is defined automatically when `NDEBUG` is defined. It can | |
127 | //! also be defined by users before including this header or defined on | |
128 | //! the command line. | |
129 | # define BOOST_HANA_CONFIG_DISABLE_ASSERTIONS | |
130 | #endif | |
131 | ||
132 | #if defined(BOOST_HANA_DOXYGEN_INVOKED) | |
133 | //! @ingroup group-config | |
134 | //! Disables concept checks in interface methods. | |
135 | //! | |
136 | //! When this macro is not defined (the default), tag-dispatched methods | |
137 | //! will make sure the arguments they are passed are models of the proper | |
138 | //! concept(s). This can be very helpful in catching programming errors, | |
139 | //! but it is also slightly less compile-time efficient. You should | |
140 | //! probably always leave the checks enabled (and hence never define this | |
141 | //! macro), except perhaps in translation units that are compiled very | |
142 | //! often but whose code using Hana is modified very rarely. | |
143 | # define BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS | |
144 | #endif | |
145 | ||
146 | #if defined(BOOST_HANA_DOXYGEN_INVOKED) | |
147 | //! @ingroup group-config | |
148 | //! Enables usage of the "string literal operator template" GNU extension. | |
149 | //! | |
150 | //! That operator is not part of the language yet, but it is supported by | |
151 | //! both Clang and GCC. This operator allows Hana to provide the nice `_s` | |
152 | //! user-defined literal for creating compile-time strings. | |
153 | //! | |
154 | //! When this macro is not defined, the GNU extension will be not used | |
155 | //! by Hana. Because this is a non-standard extension, the macro is not | |
156 | //! defined by default. | |
157 | # define BOOST_HANA_CONFIG_ENABLE_STRING_UDL | |
158 | #endif | |
159 | ||
160 | #if defined(BOOST_HANA_DOXYGEN_INVOKED) | |
161 | //! @ingroup group-config | |
162 | //! Enables additional assertions and sanity checks to be done by Hana. | |
163 | //! | |
164 | //! When this macro is defined (it is __not defined__ by default), | |
165 | //! additional sanity checks may be done by Hana. These checks may | |
166 | //! be costly to perform, either in terms of compilation time or in | |
167 | //! terms of execution time. These checks may help debugging an | |
168 | //! application during its initial development, but they should not | |
169 | //! be enabled as part of the normal configuration. | |
170 | # define BOOST_HANA_CONFIG_ENABLE_DEBUG_MODE | |
171 | #endif | |
172 | ||
173 | #endif // !BOOST_HANA_CONFIG_HPP |