1/*!
2@file
3Defines configuration macros used throughout the library.
4
5Copyright Louis Dionne 2013-2022
6Distributed 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.
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
46
47#elif defined(__clang__) && defined(_MSC_VER) // Clang-cl (Clang for Windows)
48
49# define BOOST_HANA_CONFIG_CLANG_CL
50# define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION( \
51 __clang_major__, __clang_minor__, __clang_patchlevel__)
52
53#elif defined(__clang__) && defined(__apple_build_version__) // Apple's Clang
54
55# define BOOST_HANA_CONFIG_APPLE_CLANG
56# if __apple_build_version__ >= 6020049
57# define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION(3, 6, 0)
58# endif
59
60#elif defined(__clang__) // genuine Clang
61
62# define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION( \
63 __clang_major__, __clang_minor__, __clang_patchlevel__)
64
65#elif defined(__GNUC__) // GCC
66
67# define BOOST_HANA_CONFIG_GCC BOOST_HANA_CONFIG_VERSION( \
68 __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
69
70#endif
71
72//////////////////////////////////////////////////////////////////////////////
73// Check the compiler for general C++14 capabilities
74//////////////////////////////////////////////////////////////////////////////
75#if (__cplusplus < 201400)
76# if defined(_MSC_VER)
77# if _MSC_VER < 1915
78# 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# endif
80# else
81# warning "Your compiler doesn't provide C++14 or higher capabilities. Try adding the compiler flag '-std=c++14' or '-std=c++1y'."
82# endif
83#endif
84
85//////////////////////////////////////////////////////////////////////////////
86// Caveats and other compiler-dependent options
87//////////////////////////////////////////////////////////////////////////////
88
89// `BOOST_HANA_CONFIG_HAS_CONSTEXPR_LAMBDA` enables some constructs requiring
90// `constexpr` lambdas, which are in the language starting with C++17.
91//
92// Always disabled for now because Clang only has partial support for them
93// (captureless lambdas only).
94#if defined(__cplusplus) && __cplusplus > 201402L
95# define BOOST_HANA_CONSTEXPR_STATELESS_LAMBDA constexpr
96// # define BOOST_HANA_CONFIG_HAS_CONSTEXPR_LAMBDA
97#else
98# define BOOST_HANA_CONSTEXPR_STATELESS_LAMBDA /* nothing */
99#endif
100
101// `BOOST_HANA_CONSTEXPR_LAMBDA` expands to `constexpr` if constexpr lambdas
102// are supported and to nothing otherwise.
103#if defined(BOOST_HANA_CONFIG_HAS_CONSTEXPR_LAMBDA)
104# define BOOST_HANA_CONSTEXPR_LAMBDA constexpr
105#else
106# define BOOST_HANA_CONSTEXPR_LAMBDA /* nothing */
107#endif
108
109// `BOOST_HANA_INLINE_VARIABLE` expands to `inline` when C++17 inline variables
110// are supported, and to nothing otherwise. This allows marking global variables
111// defined in a header as `inline` to avoid potential ODR violations.
112#if defined(__cplusplus) && __cplusplus > 201402L
113# define BOOST_HANA_INLINE_VARIABLE inline
114#else
115# define BOOST_HANA_INLINE_VARIABLE /* nothing */
116#endif
117
118//////////////////////////////////////////////////////////////////////////////
119// Library features and options that can be tweaked by users
120//////////////////////////////////////////////////////////////////////////////
121
122#if defined(BOOST_HANA_DOXYGEN_INVOKED) || \
123 (defined(NDEBUG) && !defined(BOOST_HANA_CONFIG_DISABLE_ASSERTIONS))
124 //! @ingroup group-config
125 //! Disables the `BOOST_HANA_*_ASSERT` macro & friends.
126 //!
127 //! When this macro is defined, the `BOOST_HANA_*_ASSERT` macro & friends
128 //! are disabled, i.e. they expand to nothing.
129 //!
130 //! This macro is defined automatically when `NDEBUG` is defined. It can
131 //! also be defined by users before including this header or defined on
132 //! the command line.
133# define BOOST_HANA_CONFIG_DISABLE_ASSERTIONS
134#endif
135
136#if defined(BOOST_HANA_DOXYGEN_INVOKED)
137 //! @ingroup group-config
138 //! Disables concept checks in interface methods.
139 //!
140 //! When this macro is not defined (the default), tag-dispatched methods
141 //! will make sure the arguments they are passed are models of the proper
142 //! concept(s). This can be very helpful in catching programming errors,
143 //! but it is also slightly less compile-time efficient. You should
144 //! probably always leave the checks enabled (and hence never define this
145 //! macro), except perhaps in translation units that are compiled very
146 //! often but whose code using Hana is modified very rarely.
147# define BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
148#endif
149
150#if defined(BOOST_HANA_DOXYGEN_INVOKED)
151 //! @ingroup group-config
152 //! Enables usage of the "string literal operator template" GNU extension.
153 //!
154 //! That operator is not part of the language yet, but it is supported by
155 //! both Clang and GCC. This operator allows Hana to provide the nice `_s`
156 //! user-defined literal for creating compile-time strings.
157 //!
158 //! When this macro is not defined, the GNU extension will be not used
159 //! by Hana. Because this is a non-standard extension, the macro is not
160 //! defined by default.
161# define BOOST_HANA_CONFIG_ENABLE_STRING_UDL
162#endif
163
164#if defined(BOOST_HANA_DOXYGEN_INVOKED)
165 //! @ingroup group-config
166 //! Enables additional assertions and sanity checks to be done by Hana.
167 //!
168 //! When this macro is defined (it is __not defined__ by default),
169 //! additional sanity checks may be done by Hana. These checks may
170 //! be costly to perform, either in terms of compilation time or in
171 //! terms of execution time. These checks may help debugging an
172 //! application during its initial development, but they should not
173 //! be enabled as part of the normal configuration.
174# define BOOST_HANA_CONFIG_ENABLE_DEBUG_MODE
175#endif
176
177#endif // !BOOST_HANA_CONFIG_HPP
178

source code of boost/libs/hana/include/boost/hana/config.hpp