|
54 | 54 | # define FMT_LIBCPP_VERSION 0
|
55 | 55 | #endif
|
56 | 56 |
|
57 |
| -// Check if exceptions are disabled. |
58 |
| -#ifdef FMT_EXCEPTIONS |
59 |
| -// Use the provided definition. |
60 |
| -#elif defined(__GNUC__) && !defined(__EXCEPTIONS) |
61 |
| -# define FMT_EXCEPTIONS 0 |
62 |
| -#elif FMT_MSC_VERSION && !_HAS_EXCEPTIONS |
63 |
| -# define FMT_EXCEPTIONS 0 |
64 |
| -#else |
65 |
| -# define FMT_EXCEPTIONS 1 |
66 |
| -#endif |
67 |
| -#if FMT_EXCEPTIONS |
68 |
| -# define FMT_TRY try |
69 |
| -# define FMT_CATCH(x) catch (x) |
70 |
| -#else |
71 |
| -# define FMT_TRY if (true) |
72 |
| -# define FMT_CATCH(x) if (false) |
73 |
| -#endif |
74 |
| - |
75 | 57 | #ifdef _MSVC_LANG
|
76 | 58 | # define FMT_CPLUSPLUS _MSVC_LANG
|
77 | 59 | #else
|
|
121 | 103 | # define FMT_CONSTEXPR
|
122 | 104 | #endif
|
123 | 105 |
|
124 |
| -// Detect C++20 extensions to constexpr and std::is_constant_evaluated. |
125 |
| -#ifndef __cpp_lib_is_constant_evaluated |
126 |
| -# define FMT_CONSTEXPR20 |
| 106 | +// Detect consteval, C++20 constexpr extensions and std::is_constant_evaluated. |
| 107 | +#if !defined(__cpp_lib_is_constant_evaluated) |
| 108 | +# define FMT_USE_CONSTEVAL 0 |
| 109 | +#elif FMT_CPLUSPLUS < 201709L |
| 110 | +# define FMT_USE_CONSTEVAL 0 |
127 | 111 | #elif FMT_GLIBCXX_RELEASE && FMT_GLIBCXX_RELEASE < 10
|
128 |
| -# define FMT_CONSTEXPR20 |
| 112 | +# define FMT_USE_CONSTEVAL 0 |
129 | 113 | #elif FMT_LIBCPP_VERSION && FMT_LIBCPP_VERSION < 10000
|
130 |
| -# define FMT_CONSTEXPR20 |
131 |
| -#elif FMT_MSC_VERSION && FMT_MSC_VERSION < 1928 |
132 |
| -# define FMT_CONSTEXPR20 |
133 |
| -#elif FMT_CPLUSPLUS >= 202002L |
134 |
| -# define FMT_CONSTEXPR20 constexpr |
135 |
| -#elif FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002 |
| 114 | +# define FMT_USE_CONSTEVAL 0 |
| 115 | +#elif defined(__apple_build_version__) && __apple_build_version__ < 14000029L |
| 116 | +# define FMT_USE_CONSTEVAL 0 // consteval is broken in Apple clang < 14. |
| 117 | +#elif FMT_MSC_VERSION && FMT_MSC_VERSION < 1929 |
| 118 | +# define FMT_USE_CONSTEVAL 0 // consteval is broken in MSVC VS2019 < 16.10. |
| 119 | +#elif defined(__cpp_consteval) |
| 120 | +# define FMT_USE_CONSTEVAL 1 |
| 121 | +#elif FMT_GCC_VERSION >= 1002 || FMT_CLANG_VERSION >= 1101 |
| 122 | +# define FMT_USE_CONSTEVAL 1 |
| 123 | +#else |
| 124 | +# define FMT_USE_CONSTEVAL 0 |
| 125 | +#endif |
| 126 | +#if FMT_USE_CONSTEVAL |
| 127 | +# define FMT_CONSTEVAL consteval |
136 | 128 | # define FMT_CONSTEXPR20 constexpr
|
137 | 129 | #else
|
| 130 | +# define FMT_CONSTEVAL |
138 | 131 | # define FMT_CONSTEXPR20
|
139 | 132 | #endif
|
140 | 133 |
|
141 |
| -#ifndef FMT_CONSTEVAL |
142 |
| -# if ((FMT_GCC_VERSION >= 1000 || FMT_CLANG_VERSION >= 1101) && \ |
143 |
| - (!defined(__apple_build_version__) || \ |
144 |
| - __apple_build_version__ >= 14000029L) && \ |
145 |
| - FMT_CPLUSPLUS >= 202002L) || \ |
146 |
| - (defined(__cpp_consteval) && \ |
147 |
| - (!FMT_MSC_VERSION || FMT_MSC_VERSION >= 1929)) |
148 |
| -// consteval is broken in MSVC before VS2019 version 16.10 and Apple clang |
149 |
| -// before 14. |
150 |
| -# define FMT_CONSTEVAL consteval |
151 |
| -# define FMT_HAS_CONSTEVAL |
152 |
| -# else |
153 |
| -# define FMT_CONSTEVAL |
154 |
| -# endif |
155 |
| -#endif |
156 |
| - |
157 |
| -#ifdef FMT_DEPRECATED |
| 134 | +// Check if exceptions are disabled. |
| 135 | +#ifdef FMT_EXCEPTIONS |
158 | 136 | // Use the provided definition.
|
159 |
| -#elif FMT_HAS_CPP14_ATTRIBUTE(deprecated) |
160 |
| -# define FMT_DEPRECATED [[deprecated]] |
| 137 | +#elif defined(__GNUC__) && !defined(__EXCEPTIONS) |
| 138 | +# define FMT_EXCEPTIONS 0 |
| 139 | +#elif FMT_MSC_VERSION && !_HAS_EXCEPTIONS |
| 140 | +# define FMT_EXCEPTIONS 0 |
161 | 141 | #else
|
162 |
| -# define FMT_DEPRECATED /* deprecated */ |
| 142 | +# define FMT_EXCEPTIONS 1 |
| 143 | +#endif |
| 144 | +#if FMT_EXCEPTIONS |
| 145 | +# define FMT_TRY try |
| 146 | +# define FMT_CATCH(x) catch (x) |
| 147 | +#else |
| 148 | +# define FMT_TRY if (true) |
| 149 | +# define FMT_CATCH(x) if (false) |
163 | 150 | #endif
|
164 | 151 |
|
165 | 152 | // Disable [[noreturn]] on MSVC/NVCC because of bogus unreachable code warnings.
|
166 |
| -#if FMT_EXCEPTIONS && FMT_HAS_CPP_ATTRIBUTE(noreturn) && !FMT_MSC_VERSION && \ |
| 153 | +#if FMT_HAS_CPP_ATTRIBUTE(noreturn) && FMT_EXCEPTIONS && !FMT_MSC_VERSION && \ |
167 | 154 | !defined(__NVCC__)
|
168 | 155 | # define FMT_NORETURN [[noreturn]]
|
169 | 156 | #else
|
|
178 | 165 | # endif
|
179 | 166 | #endif
|
180 | 167 |
|
| 168 | +#ifdef FMT_DEPRECATED |
| 169 | +// Use the provided definition. |
| 170 | +#elif FMT_HAS_CPP14_ATTRIBUTE(deprecated) |
| 171 | +# define FMT_DEPRECATED [[deprecated]] |
| 172 | +#else |
| 173 | +# define FMT_DEPRECATED /* deprecated */ |
| 174 | +#endif |
| 175 | + |
181 | 176 | #ifdef FMT_INLINE
|
182 | 177 | // Use the provided definition.
|
183 | 178 | #elif FMT_GCC_VERSION || FMT_CLANG_VERSION
|
|
186 | 181 | # define FMT_INLINE inline
|
187 | 182 | #endif
|
188 | 183 |
|
| 184 | +#if FMT_GCC_VERSION || FMT_CLANG_VERSION |
| 185 | +# define FMT_VISIBILITY(value) __attribute__((visibility(value))) |
| 186 | +#else |
| 187 | +# define FMT_VISIBILITY(value) |
| 188 | +#endif |
| 189 | + |
189 | 190 | #ifndef FMT_GCC_PRAGMA
|
190 | 191 | // Workaround a _Pragma bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59884
|
191 | 192 | // and an nvhpc warning: https://github.com/fmtlib/fmt/pull/2582.
|
|
195 | 196 | # define FMT_GCC_PRAGMA(arg)
|
196 | 197 | # endif
|
197 | 198 | #endif
|
| 199 | + |
198 | 200 | #if FMT_MSC_VERSION
|
199 | 201 | # define FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__))
|
200 |
| -#else |
201 |
| -# define FMT_MSC_WARNING(...) |
202 |
| -#endif |
203 |
| - |
204 |
| -#ifdef _MSC_VER |
205 | 202 | # define FMT_UNCHECKED_ITERATOR(It) \
|
206 | 203 | using _Unchecked_type = It // Mark iterator as checked.
|
207 | 204 | #else
|
| 205 | +# define FMT_MSC_WARNING(...) |
208 | 206 | # define FMT_UNCHECKED_ITERATOR(It) using unchecked_type = It
|
209 | 207 | #endif
|
210 | 208 |
|
|
223 | 221 | # define FMT_END_EXPORT
|
224 | 222 | #endif
|
225 | 223 |
|
226 |
| -#if FMT_GCC_VERSION || FMT_CLANG_VERSION |
227 |
| -# define FMT_VISIBILITY(value) __attribute__((visibility(value))) |
228 |
| -#else |
229 |
| -# define FMT_VISIBILITY(value) |
230 |
| -#endif |
231 |
| - |
232 | 224 | #if !defined(FMT_HEADER_ONLY) && defined(_WIN32)
|
233 | 225 | # if defined(FMT_LIB_EXPORT)
|
234 | 226 | # define FMT_API __declspec(dllexport)
|
@@ -1272,7 +1264,7 @@ template <typename Context> class value {
|
1272 | 1264 | template <typename T> FMT_CONSTEXPR20 FMT_INLINE value(T& val) {
|
1273 | 1265 | using value_type = remove_const_t<T>;
|
1274 | 1266 | // T may overload operator& e.g. std::vector<bool>::reference in libc++.
|
1275 |
| -#ifdef __cpp_if_constexpr |
| 1267 | +#if defined(__cpp_if_constexpr) |
1276 | 1268 | if constexpr (std::is_same<decltype(&val), T*>::value)
|
1277 | 1269 | custom.value = const_cast<value_type*>(&val);
|
1278 | 1270 | #endif
|
@@ -2749,7 +2741,7 @@ template <typename Char, typename... Args> class basic_format_string {
|
2749 | 2741 | (std::is_base_of<detail::view, remove_reference_t<Args>>::value &&
|
2750 | 2742 | std::is_reference<Args>::value)...>() == 0,
|
2751 | 2743 | "passing views as lvalues is disallowed");
|
2752 |
| -#ifdef FMT_HAS_CONSTEVAL |
| 2744 | +#if FMT_USE_CONSTEVAL |
2753 | 2745 | if constexpr (detail::count_named_args<Args...>() ==
|
2754 | 2746 | detail::count_statically_named_args<Args...>()) {
|
2755 | 2747 | using checker =
|
|
0 commit comments