Open usefulcat opened 3 years ago
Ran into the same problem. I think this is a bug in gcc. I just opened a question stackoverflow regarding this: https://stackoverflow.com/questions/69540048/gcc-ambiguous-inherited-increment
I don't think that the hot-fix (using
the operators) will work in general for NamedType, since it would have to know if it is pre- and postincrementable. But adding the following lines to struct Arithmetic
fixes it for arithmetic types at least:
using PostIncrementable<T>::operator++;
using PreIncrementable<T>::operator++;
using PostDecrementable<T>::operator--;
using PreDecrementable<T>::operator--;
I will add a pull request for this.
I added the following test case to tests.cpp, which is just a trivial combination of the contents of the PreIncrementable and PostIncrementable tests:
gcc 9.3 fails to compile it, saying "error: request for member ‘operator++’ is ambiguous".
I thought I would try fixing it myself but so far I haven't been able to figure out why it doesn't work, let alone how to fix it. This problem also affects any type that uses Arithmetic, which is how I originally discovered it.