[caffe2] Make ListIterator compatible with libc++ 15 (#83189)
Summary:
We're working on upgrading our Android native code to build with libc++
15 (it currently uses libc++ 13). libc++ 15 diagnoses iterators whose
`iterator_traits<It>::reference` does not match the return type of `*it`:
```
third-party/llvm-project/15.x-android/llvm-project/libcxx/include/__algorithm/iterator_operations.h:84:5: error: static_assert failed due to requirement 'is_same<c10::impl::ListElementReference<at::Tensor, std::__wrap_iter<c10::IValue *>>, at::Tensor &>::value' "It looks like your iterator's `iterator_traits<It>::reference` does not match the return type of dereferencing the iterator, i.e., calling `*it`. This is undefined behavior according to [input.iterators] and can lead to dangling reference issues at runtime, so we are flagging this."
```
This was added by https://reviews.llvm.org/D130538, and there's some
discussion of the rationale there.
Set the `iterator_traits` for `ListIterator` appropriately to avoid this
error. I'm not sure if `iterator_traits<It>::pointer` should also be
updated to match.
Reviewed By: swolchok
Differential Revision: D38565649
Pull Request resolved: https://github.com/pytorch/pytorch/pull/83189
Approved by: https://github.com/swolchok