[PATCH] D111283: [clang] template / auto deduction deduces common sugar
Louis Dionne via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 21 14:03:54 PDT 2021
ldionne added a comment.
In D111283#3056748 <https://reviews.llvm.org/D111283#3056748>, @rsmith wrote:
> Do you have examples showing what this does in practice for errors in real-world code? I'm concerned that stripping back to the common type sugar may produce an unintuitive result in some cases, although it certainly does seem at least theoretically nice to use a commutative and associative function to combine deductions like this. The kind of thing I'd be worried about would be (eg) a container where the `iterator` and `const_iterator` are the same, but where the common sugar of `T::iterator` and `T::const_iterator` are some internal type that the user has never heard of. In general it seems like this sugar stripping could result in types that are distant from the user's code. As an extreme example, in the case where one of the types is canonical and the other is not, it seems like stripping all the way back to the canonical type would be worse than ignoring the canonical version of the type and keeping the sugared version.
FWIW, I believe in those cases the best tool might be some sort of attribute to treat an alias like a "strong typedef".
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111283/new/
https://reviews.llvm.org/D111283
More information about the cfe-commits
mailing list