Cast return value of vector.at() to void to avoid nodiscard warning in MSVC. (#22061)
Summary:
Fix https://github.com/pytorch/pytorch/issues/22053
Pull Request resolved: https://github.com/pytorch/pytorch/pull/22061
Differential Revision: D15957983
Pulled By: ezyang
fbshipit-source-id: e4416c5f0db2bc6b8bfaa27be52b942148ec7b3d
diff --git a/aten/src/ATen/core/List_inl.h b/aten/src/ATen/core/List_inl.h
index 0660d30..43b6ebf 100644
--- a/aten/src/ATen/core/List_inl.h
+++ b/aten/src/ATen/core/List_inl.h
@@ -109,7 +109,7 @@
template<class T>
typename List<T>::internal_reference_type List<T>::operator[](size_type pos) const {
- impl_->list.at(pos); // Throw the exception if it is out of range.
+ static_cast<void>(impl_->list.at(pos)); // Throw the exception if it is out of range.
return {impl_->list.begin() + pos};
}