[PATCH] D35043: [ADT] Enable reverse iteration for DenseMap
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 6 22:56:24 PDT 2017
Sorry - yes, I think it is best if this only applies to pointer like types
(since arguably at least there's implementation defined ordering for llvms
hash containers for now, it's sort of relying on an implementation detail
but anyway
What I meant about is_pointer is that I was looking for something probably
named is_pointer_like (or perhaps IsPointerLike), but whatever the name -
the implementation is what I was/am concerned with. I don't want it tone
another trait that everything that currently implements
PointerLikeTypeTraots would have to also implement. I was hoping to define
IsPointerLike in terms of the existing IsPointerLikeTypeTraits. So that the
two would not diverge unnecessarily.
On Sun., 6 Aug. 2017, 10:33 pm Grang, Mandeep Singh <mgrang at codeaurora.org>
wrote:
> I have removed the is_pointer trait. I thought we wanted it to work
> exactly for all pointer and pointer-like types. That's the reason I had an
> is_pointer trait.
>
> So now how do we define the behavior for reverse iteration? It is no
> longer tied to pointer types, right? As long as a type is complete it will
> reverse iterate.
>
> On 8/6/2017 3:17 PM, David Blaikie wrote:
>
> I'd still prefer not to build another trait for this unless we have to -
> is there a reason we'd want is_pointer to not be true for some types that
> are PointerLike? (or conversely, for it to be true for some types that
> aren't PointerLike)
>
> On Sun, Aug 6, 2017 at 11:52 AM Mandeep Singh Grang via Phabricator <
> reviews at reviews.llvm.org> wrote:
>
>> mgrang added inline comments.
>>
>>
>> ================
>> Comment at: include/llvm/Support/PointerLikeTypeTraits.h:35
>> +// Trait to check if T is pointer.
>> +template<typename T>
>> +struct is_pointer { static const bool value = false; };
>> ----------------
>> mgrang wrote:
>> > Just checking if T is a complete type is not enough due to the presence
>> of specialization for const T:
>> > template <typename T> class PointerLikeTypeTraits<const T>
>> >
>> > In this case, for a const int the type is complete but it's not a
>> pointer type. So to handle such cases I had to check for is_pointer too.
>> We might as well not check for is_complete and just check for is_pointer,
>> and then add more specialization for is_pointer of other ptr types (like
>> shared, unique ptr, etc)?
>>
>>
>> Repository:
>> rL LLVM
>>
>> https://reviews.llvm.org/D35043
>>
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170807/a6fede6e/attachment.html>
More information about the llvm-commits
mailing list