[PATCH] D113158: ADT: Fix const-correctness of iterator adaptors
Duncan P. N. Exon Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 3 18:07:36 PDT 2021
dexonsmith marked an inline comment as done.
dexonsmith added inline comments.
================
Comment at: llvm/unittests/ADT/IteratorTest.cpp:104
+ EXPECT_EQ(true, canAssignFromInt(*I)); // int *
+ EXPECT_EQ(true, canAssignFromInt(*IC)); // int *const
+ EXPECT_EQ(false, canAssignFromInt(*CI)); // const int *
----------------
mehdi_amini wrote:
> dexonsmith wrote:
> > I expected this test to fail (and the proof below not to compile) after https://reviews.llvm.org/D112981, but locally it seemed fine. It appears that `const ReferenceT` is equivalent to `int&` when `ReferenceT==int&`... which confuses me a bit, but so be it.
> Right this always confuses me as well, this is "reference is a const reference, but not a reference to const", so the "const" applies to the reference, but a reference is always "const" (as in `int *const`).
> This is why we have `std::remove_reference_t` in generic code right?
>
Right, right; thanks!
In which case, https://reviews.llvm.org/D112981 only adds `const` to by-value returns (which are super rare, outside of proxies).
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113158/new/
https://reviews.llvm.org/D113158
More information about the llvm-commits
mailing list