From ff832a57b402a583a9411c17143f7f6308460b15 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Mon, 22 Sep 2025 23:55:19 -0700 Subject: [PATCH] [ADT] Apply Rule of Five to StringTable::Iterator StringTable::Iterator has a user-defined copy assignment operator, a defaulted copy constructor, and a defaulted move constructor. This patch makes the copy assignment operator defaulted and adds a defaulted move assignment operator to adhere to the Rule of Five while making the operators constexpr. --- llvm/include/llvm/ADT/StringTable.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/llvm/include/llvm/ADT/StringTable.h b/llvm/include/llvm/ADT/StringTable.h index 575b3c929e40c..9422a6da1ce8e 100644 --- a/llvm/include/llvm/ADT/StringTable.h +++ b/llvm/include/llvm/ADT/StringTable.h @@ -118,12 +118,8 @@ class StringTable { constexpr Iterator(const Iterator &RHS) = default; constexpr Iterator(Iterator &&RHS) = default; - Iterator &operator=(const Iterator &RHS) { - Table = RHS.Table; - O = RHS.O; - S = RHS.S; - return *this; - } + constexpr Iterator &operator=(const Iterator &RHS) = default; + constexpr Iterator &operator=(Iterator &&RHS) = default; bool operator==(const Iterator &RHS) const { assert(Table == RHS.Table && "Compared iterators for unrelated tables!");