[PATCH] D113158: ADT: Fix const-correctness of iterator adaptors

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 9 15:42:03 PST 2021


dblaikie added a comment.

> There are lots of custom iterators that *only* define a non-const qualified `operator*()`. In some cases, it'd make sense to make a member `mutable`, or change the return type to always be `const`-qualified. But perhaps not in every case?

I think that covers all cases I can think of, and seems like the right thing - but if it means lots of cleanup, and just keeping/making two overloads (const/non-const) that both return non-const ref (well, return ref, whatever that is - const ref for const_iterators (that themselves may or may not be const... you know what I mean)) is significantly cheaper right now - I'd be OK with that. Seems like it'd make things incrementally better at least - leave a comment aobut it being a stop-gap, not a complete solution, maybe some comments about the functionality or patterns that are deprecated/urge people towards just writing the one const op*?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113158/new/

https://reviews.llvm.org/D113158



More information about the llvm-commits mailing list