3 Defines configuration macros used throughout the library.
5 @copyright Louis Dionne 2013-2017
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)
10 #ifndef BOOST_HANA_CONFIG_HPP
11 #define BOOST_HANA_CONFIG_HPP
13 #include <boost/hana/version.hpp>
16 //////////////////////////////////////////////////////////////////////////////
17 // Detect the compiler
18 //////////////////////////////////////////////////////////////////////////////
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.
25 # pragma message("Warning: the native Microsoft compiler is not supported due to lack of proper C++14 support.")
28 // Multiple copy/move ctors
29 # define BOOST_HANA_WORKAROUND_MSVC_MULTIPLECTOR_106654
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
35 // 3. Issues fixed conditionally
36 // Requires __declspec(empty_bases)
37 // Empty base optimization
38 # define BOOST_HANA_WORKAROUND_MSVC_EMPTYBASE
40 // Requires /experimental:preprocessor
41 // Variadic macro expansion
42 # if !defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL
43 # define BOOST_HANA_WORKAROUND_MSVC_PREPROCESSOR_616033
47 #elif defined(__clang__) && defined(_MSC_VER) // Clang-cl (Clang for Windows)
49 # define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION( \
50 __clang_major__, __clang_minor__, __clang_patchlevel__)
52 #elif defined(__clang__) && defined(__apple_build_version__) // Apple's Clang
54 # if __apple_build_version__ >= 6020049
55 # define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION(3, 6, 0)
58 #elif defined(__clang__) // genuine Clang
60 # define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION( \
61 __clang_major__, __clang_minor__, __clang_patchlevel__)
63 #elif defined(__GNUC__) // GCC
65 # define BOOST_HANA_CONFIG_GCC BOOST_HANA_CONFIG_VERSION( \
66 __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
70 //////////////////////////////////////////////////////////////////////////////
71 // Check the compiler for general C++14 capabilities
72 //////////////////////////////////////////////////////////////////////////////
73 #if (__cplusplus < 201400)
74 # if defined(_MSC_VER)
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'.")
79 # warning "Your compiler doesn't provide C++14 or higher capabilities. Try adding the compiler flag '-std=c++14' or '-std=c++1y'."
83 //////////////////////////////////////////////////////////////////////////////
84 // Caveats and other compiler-dependent options
85 //////////////////////////////////////////////////////////////////////////////
87 // `BOOST_HANA_CONFIG_HAS_CONSTEXPR_LAMBDA` enables some constructs requiring
88 // `constexpr` lambdas, which are in the language starting with C++17.
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
96 # define BOOST_HANA_CONSTEXPR_STATELESS_LAMBDA /* nothing */
99 // `BOOST_HANA_CONSTEXPR_LAMBDA` expands to `constexpr` if constexpr lambdas
100 // are supported and to nothing otherwise.
101 #if defined(BOOST_HANA_CONFIG_HAS_CONSTEXPR_LAMBDA)
102 # define BOOST_HANA_CONSTEXPR_LAMBDA constexpr
104 # define BOOST_HANA_CONSTEXPR_LAMBDA /* nothing */
107 //////////////////////////////////////////////////////////////////////////////
109 //////////////////////////////////////////////////////////////////////////////
110 #define BOOST_HANA_NAMESPACE_BEGIN namespace boost { namespace hana {
112 #define BOOST_HANA_NAMESPACE_END }}
114 //////////////////////////////////////////////////////////////////////////////
115 // Library features and options that can be tweaked by users
116 //////////////////////////////////////////////////////////////////////////////
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.
123 //! When this macro is defined, the `BOOST_HANA_*_ASSERT` macro & friends
124 //! are disabled, i.e. they expand to nothing.
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
132 #if defined(BOOST_HANA_DOXYGEN_INVOKED)
133 //! @ingroup group-config
134 //! Disables concept checks in interface methods.
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
146 #if defined(BOOST_HANA_DOXYGEN_INVOKED)
147 //! @ingroup group-config
148 //! Enables usage of the "string literal operator template" GNU extension.
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.
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
160 #if defined(BOOST_HANA_DOXYGEN_INVOKED)
161 //! @ingroup group-config
162 //! Enables additional assertions and sanity checks to be done by Hana.
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
173 #endif // !BOOST_HANA_CONFIG_HPP