|
21 | 21 | #endif |
22 | 22 |
|
23 | 23 | // The fmt library version in the form major * 10000 + minor * 100 + patch. |
24 | | -#define FMT_VERSION 120000 |
| 24 | +#define FMT_VERSION 120100 |
25 | 25 |
|
26 | 26 | // Detect compiler versions. |
27 | 27 | #if defined(__clang__) && !defined(__ibmxl__) |
|
114 | 114 | #endif |
115 | 115 |
|
116 | 116 | // Detect consteval, C++20 constexpr extensions and std::is_constant_evaluated. |
117 | | -#if !defined(__cpp_lib_is_constant_evaluated) |
| 117 | +#ifdef FMT_USE_CONSTEVAL |
| 118 | +// Use the provided definition. |
| 119 | +#elif !defined(__cpp_lib_is_constant_evaluated) |
118 | 120 | # define FMT_USE_CONSTEVAL 0 |
119 | 121 | #elif FMT_CPLUSPLUS < 201709L |
120 | 122 | # define FMT_USE_CONSTEVAL 0 |
@@ -234,6 +236,7 @@ FMT_PRAGMA_GCC(optimize("Og")) |
234 | 236 | # define FMT_GCC_OPTIMIZED |
235 | 237 | #endif |
236 | 238 | FMT_PRAGMA_CLANG(diagnostic push) |
| 239 | +FMT_PRAGMA_GCC(diagnostic push) |
237 | 240 |
|
238 | 241 | #ifdef FMT_ALWAYS_INLINE |
239 | 242 | // Use the provided definition. |
@@ -414,8 +417,12 @@ inline auto map(int128_opt) -> monostate { return {}; } |
414 | 417 | inline auto map(uint128_opt) -> monostate { return {}; } |
415 | 418 | #endif |
416 | 419 |
|
417 | | -#ifndef FMT_USE_BITINT |
418 | | -# define FMT_USE_BITINT (FMT_CLANG_VERSION >= 1500) |
| 420 | +#ifdef FMT_USE_BITINT |
| 421 | +// Use the provided definition. |
| 422 | +#elif FMT_CLANG_VERSION >= 1500 && !defined(__CUDACC__) |
| 423 | +# define FMT_USE_BITINT 1 |
| 424 | +#else |
| 425 | +# define FMT_USE_BITINT 0 |
419 | 426 | #endif |
420 | 427 |
|
421 | 428 | #if FMT_USE_BITINT |
@@ -918,7 +925,10 @@ class locale_ref { |
918 | 925 | constexpr locale_ref() : locale_(nullptr) {} |
919 | 926 |
|
920 | 927 | template <typename Locale, FMT_ENABLE_IF(sizeof(Locale::collate) != 0)> |
921 | | - locale_ref(const Locale& loc); |
| 928 | + locale_ref(const Locale& loc) : locale_(&loc) { |
| 929 | + // Check if std::isalpha is found via ADL to reduce the chance of misuse. |
| 930 | + isalpha('x', loc); |
| 931 | + } |
922 | 932 |
|
923 | 933 | inline explicit operator bool() const noexcept { return locale_ != nullptr; } |
924 | 934 | #endif // FMT_USE_LOCALE |
@@ -1844,12 +1854,17 @@ template <typename T> class buffer { |
1844 | 1854 | void |
1845 | 1855 | append(const U* begin, const U* end) { |
1846 | 1856 | while (begin != end) { |
| 1857 | + auto size = size_; |
| 1858 | + auto free_cap = capacity_ - size; |
1847 | 1859 | auto count = to_unsigned(end - begin); |
1848 | | - try_reserve(size_ + count); |
1849 | | - auto free_cap = capacity_ - size_; |
1850 | | - if (free_cap < count) count = free_cap; |
| 1860 | + if (free_cap < count) { |
| 1861 | + grow_(*this, size + count); |
| 1862 | + size = size_; |
| 1863 | + free_cap = capacity_ - size; |
| 1864 | + count = count < free_cap ? count : free_cap; |
| 1865 | + } |
1851 | 1866 | // A loop is faster than memcpy on small sizes. |
1852 | | - T* out = ptr_ + size_; |
| 1867 | + T* out = ptr_ + size; |
1853 | 1868 | for (size_t i = 0; i < count; ++i) out[i] = begin[i]; |
1854 | 1869 | size_ += count; |
1855 | 1870 | begin += count; |
@@ -2983,6 +2998,7 @@ FMT_INLINE void println(format_string<T...> fmt, T&&... args) { |
2983 | 2998 | return fmt::println(stdout, fmt, static_cast<T&&>(args)...); |
2984 | 2999 | } |
2985 | 3000 |
|
| 3001 | +FMT_PRAGMA_GCC(diagnostic pop) |
2986 | 3002 | FMT_PRAGMA_CLANG(diagnostic pop) |
2987 | 3003 | FMT_PRAGMA_GCC(pop_options) |
2988 | 3004 | FMT_END_EXPORT |
|
0 commit comments