Skip to content

Commit f7adfb5

Browse files
committed
[RF] Implement move constructor/assignment operator of RooLinkedListIter
Setting the move constructor and move assignment operator to = default causes linker errors because the copy assignment operator is not implemented in the TIterator base class. Having the RooLinkedListIter move constructor and assignment operators work is important to keep user code compatibility.
1 parent d2e8a1c commit f7adfb5

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

roofit/roofitcore/inc/RooLinkedListIter.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,18 @@ class RooLinkedListIter final : public TIterator {
210210
}
211211

212212
RooLinkedListIter(const RooLinkedListIter &) = delete;
213-
RooLinkedListIter(RooLinkedListIter &&) = default;
214213
RooLinkedListIter & operator=(const RooLinkedListIter &) = delete;
215-
RooLinkedListIter & operator=(RooLinkedListIter &&) = default;
214+
215+
// Setting the move constructor and assignment operator to = default might
216+
// seem to work, but it causes linker errors when using it because
217+
// TIterator::operator= is not implemented.
218+
RooLinkedListIter(RooLinkedListIter && other)
219+
: fIterImpl{std::move(other.fIterImpl)}
220+
{}
221+
RooLinkedListIter & operator=(RooLinkedListIter && other) {
222+
fIterImpl = std::move(other.fIterImpl);
223+
return *this;
224+
}
216225

217226
TIterator &operator=(const TIterator & other) override {fIterImpl->operator=(other); return *this;}
218227
const TCollection *GetCollection() const override {return nullptr;}

0 commit comments

Comments
 (0)