Open
Bug 1826935
Opened 2 years ago
Updated 11 months ago
`Reversed` does not work with a temporary object
Categories
(Core :: MFBT, defect)
Core
MFBT
Tracking
()
NEW
People
(Reporter: masayuki, Unassigned)
References
Details
AutoTArray<RefPtr<Element>, 10> elements;
for (const auto& e : Reversed(elements.Clone())) {
e->foo();
}
In this case, the result of Clone()
creates a temporary object which is not available from the range-based for loop.
I think that there should be a class of reversing the range with moving and storing the temporary object. Then, such for loop does not need to create an array outside the for
.
If this is not reasonable, I think that this should cause an error of clang-plugin if Reversed
is called with a temporary object.
If this is not reasonable, I think that this should cause an error of clang-plugin if Reversed is called with a temporary object.
I wonder it can define an rvalue overload and add static_assert.
Updated•11 months ago
|
Severity: -- → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•