On Friday, 27 September 2024 at 20:28:21 UTC, H. S. Teoh wrote:
...
The reason for (2) is that in UFCS chains, the only thing you
really only care about is what kind of range it is that you're
dealing with, and maybe the element type. What exactly the
container type is, is unimportant, and in fact, stating it
explicitly is detrimental to maintenance because the library
that gave you that type may change the concrete type in the
future while retaining the same range and element type. So by
naming an explicit type for the range, you introduce a
potential needless breakage in your code when you next upgrade
the library. Instead, use `auto` to let the compiler figure
out what the concrete type is, as long as it conforms to the
expected range semantics and has a compatible element type,
your code will continue to work as before.
...
Once my range didn't work because I used **auto** instead of
**bool** in the standard InputRange functions (I think it had
something to do with **length()** too...). As I said, I'm not
sure, it could also be **size_t length()**. So there are subtle
cases where we should use auto, I wish I could show you but I
can't think of any.
SDB@79