-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Provide TIter &TIter::operator=(TIterator *it) signature #7633
Copy link
Copy link
Closed
Description
Copy post from Mattermost:
Normally one writes:
TList *lst = new TList();
TIter iter(lst);
This works fine.
In many places of RooFit (and also in some other classes) one can see following syntax:
TIter iter = lst->MakeIterator();
It is also fine while where is constructor signature TIter(TIterator *it).
But if one does again:
iter = lst->MakeIterator();
One do not get that one expects. While C++ does:
- creates temporary TIter instance,
- Calls TIter &operator=(const TIter &rhs)
- deletes temporary
TIterinstance with originalTIteratorobject which was created bylst->MakeIterator().
Means we have unnecessary duplication of TIterator in between. Moreover, following code MAY produce wrong results:
iter = lst->MakeIterator(kIterBackward);
It depends if assign operator implemented properly for derived TIterator classes.
Probably, we should define assign operator abstract:
virtual TIterator &operator=(const TIterator &) = 0;
To ensure that all derived classes implement it
Reactions are currently unavailable