Simplify warning suppression

This commit is contained in:
Victor Zverovich 2026-01-29 22:20:13 -08:00
parent 71c63792dd
commit cf74caae38
2 changed files with 11 additions and 7 deletions

View File

@ -223,11 +223,6 @@
#else #else
# define FMT_PRAGMA_CLANG(x) # define FMT_PRAGMA_CLANG(x)
#endif #endif
#if FMT_MSC_VERSION
# define FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__))
#else
# define FMT_MSC_WARNING(...)
#endif
// Enable minimal optimizations for more compact code in debug mode. // Enable minimal optimizations for more compact code in debug mode.
FMT_PRAGMA_GCC(push_options) FMT_PRAGMA_GCC(push_options)
@ -1741,9 +1736,12 @@ template <typename T> class buffer {
protected: protected:
// Don't initialize ptr_ since it is not accessed to save a few cycles. // Don't initialize ptr_ since it is not accessed to save a few cycles.
FMT_MSC_WARNING(suppress : 26495)
constexpr buffer(grow_fun grow, size_t sz) noexcept constexpr buffer(grow_fun grow, size_t sz) noexcept
: size_(sz), capacity_(sz), grow_(grow) {} : size_(sz), capacity_(sz), grow_(grow) {
#if FMT_MSC_VERSION
ptr_ = nullptr; // Suppress warning 26495.
#endif
}
constexpr buffer(grow_fun grow, T* p = nullptr, size_t sz = 0, constexpr buffer(grow_fun grow, T* p = nullptr, size_t sz = 0,
size_t cap = 0) noexcept size_t cap = 0) noexcept

View File

@ -156,6 +156,12 @@
# define FMT_CONSTEXPR_STRING # define FMT_CONSTEXPR_STRING
#endif #endif
#if FMT_MSC_VERSION
# define FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__))
#else
# define FMT_MSC_WARNING(...)
#endif
// GCC 4.9 doesn't support qualified names in specializations. // GCC 4.9 doesn't support qualified names in specializations.
namespace std { namespace std {
template <typename T> struct iterator_traits<fmt::basic_appender<T>> { template <typename T> struct iterator_traits<fmt::basic_appender<T>> {