[libc++] Counter<T>'s assignment operator shouldn't ++gConstructed

This has been here since d5f461ca03, but assigning into an existing
Counter object definitely doesn't create a new object. This causes the
count to "leak" higher and higher, inside algorithms based on swapping.
This commit is contained in:
Arthur O'Dwyer 2023-02-09 13:06:52 -05:00 committed by Louis Dionne
parent 755535b5eb
commit a9f384994b

View File

@ -25,7 +25,7 @@ public:
Counter& operator=(const Counter& rhs) { data_ = rhs.data_; return *this; }
#if TEST_STD_VER >= 11
Counter(Counter&& rhs) : data_(std::move(rhs.data_)) { ++gConstructed; }
Counter& operator=(Counter&& rhs) { ++gConstructed; data_ = std::move(rhs.data_); return *this; }
Counter& operator=(Counter&& rhs) { data_ = std::move(rhs.data_); return *this; }
#endif
~Counter() { --gConstructed; }