From 819ad2547b7186c229ee3254121efa1861811e34 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Tue, 28 Jan 2025 19:52:22 -0500 Subject: [PATCH 1/3] src: disallow copy/move fns/constructors --- src/util.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/util.h b/src/util.h index eb6da3487737d6..f13eb9dee1de6d 100644 --- a/src/util.h +++ b/src/util.h @@ -388,6 +388,16 @@ constexpr size_t strsize(const T (&)[N]) { template class MaybeStackBuffer { public: + // Disallow move constructor + MaybeStackBuffer(MaybeStackBuffer&&) = delete; + // Disallow copy constructor + MaybeStackBuffer(const MaybeStackBuffer&) = delete; + // Disallow move assignment operator + MaybeStackBuffer& operator=(MaybeStackBuffer&& other) = delete; + // Disallow copy assignment operator + MaybeStackBuffer& + operator=(MaybeStackBuffer& other) = delete; // NOLINT(runtime/references) + const T* out() const { return buf_; } From 1ec10653e613d15024ecd58dc356935e256aa4b6 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Wed, 29 Jan 2025 10:20:06 -0500 Subject: [PATCH 2/3] Update src/util.h Co-authored-by: Chengzhong Wu --- src/util.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/util.h b/src/util.h index f13eb9dee1de6d..9ad7e24b4a5b94 100644 --- a/src/util.h +++ b/src/util.h @@ -388,15 +388,11 @@ constexpr size_t strsize(const T (&)[N]) { template class MaybeStackBuffer { public: - // Disallow move constructor - MaybeStackBuffer(MaybeStackBuffer&&) = delete; // Disallow copy constructor MaybeStackBuffer(const MaybeStackBuffer&) = delete; - // Disallow move assignment operator - MaybeStackBuffer& operator=(MaybeStackBuffer&& other) = delete; // Disallow copy assignment operator MaybeStackBuffer& - operator=(MaybeStackBuffer& other) = delete; // NOLINT(runtime/references) + operator=(const MaybeStackBuffer& other) = delete; const T* out() const { return buf_; From e9ddc7c02730b4cdd3bee234401dadecd20903af Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Wed, 29 Jan 2025 17:06:59 -0500 Subject: [PATCH 3/3] apvoid copy --- src/debug_utils-inl.h | 2 +- src/util.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/debug_utils-inl.h b/src/debug_utils-inl.h index 86dc29d6bbe9fb..3736663d9977c0 100644 --- a/src/debug_utils-inl.h +++ b/src/debug_utils-inl.h @@ -50,7 +50,7 @@ struct ToStringHelper { template >> - static std::string BaseConvert(T value) { + static std::string BaseConvert(T& value) { // NOLINT(runtime/references) return Convert(std::forward(value)); } }; diff --git a/src/util.h b/src/util.h index 9ad7e24b4a5b94..84583d80c598ba 100644 --- a/src/util.h +++ b/src/util.h @@ -391,8 +391,7 @@ class MaybeStackBuffer { // Disallow copy constructor MaybeStackBuffer(const MaybeStackBuffer&) = delete; // Disallow copy assignment operator - MaybeStackBuffer& - operator=(const MaybeStackBuffer& other) = delete; + MaybeStackBuffer& operator=(const MaybeStackBuffer& other) = delete; const T* out() const { return buf_;