[PATCH] D113158: ADT: Fix const-correctness of iterator adaptors
Mehdi AMINI via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 3 17:57:15 PDT 2021
mehdi_amini added a comment.
Thanks for all the fixes!
@dblaikie is a better reviewer than I am for this, I'm easily lost in the layers of iterators wrapping iterators...
================
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 *
----------------
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?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113158/new/
https://reviews.llvm.org/D113158
More information about the llvm-commits
mailing list