Closed guhwanbae closed 2 years ago
Hi!
The DerivedT
is required to ensure the right types are used. Otherwise, you could compare iterators that use the iterator_facade
of the wrong type (immer::vector
with immer::map
) creating undefined behavior. Reversing the parameter order is also feasible I think. I will try reproduce this case in a test and fix this.
Thanks a lot for reporting the issue!
I'm trying to build my project with c++2a version in Clang(clang++-10). But the compiler reports errors which is related to an ambiguous operator.
Example:
Compiler Report:
Since C++20, The compiler considers reversed order. So it has two candidates.
First candidate is perfectly match in example case, but parameter type is base class. Second candidate has perfect parameter type, but it is calling base method.
I fix this problem by just changing parameter type of the operator==.
But I'm not sure of original intention. Why iterator_facade's comparison operators has DerivedT type parameter, not iterator_facade?
In my opinion, operator==(const iterator_facade&) is enough since C++20. (Or global type operator==(iterator_facade, iterator_facade) Compiler will make operator!= from operator==. Like !(lhs == rhs). And it considers reversed order.