[PATCH] D125609: [ADT] Adopt the new casting infrastructure for PointerUnion
Sheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat May 14 21:12:10 PDT 2022
0x59616e added a comment.
Thanks for feedback ;)
In D125609#3514018 <https://reviews.llvm.org/D125609#3514018>, @bzcheeseman wrote:
> In D125609#3514009 <https://reviews.llvm.org/D125609#3514009>, @0x59616e wrote:
>
>> Define `CastInfoPointerUnionImpl` as below :
>>
>> template <typename... PTs> struct CastInfoPointerUnionImpl {
>> using From = PointerUnion<PTs...>;
>>
>> template <typename To> static inline bool isPossible(From &F) {
>> return F.Val.getInt() == FirstIndexOfType<To, PTs...>::value;
>> }
>>
>> template <typename To> static To doCast(From &F) {
>> assert(isPossible<To>(F) && "cast to an incompatible type !");
>> return PointerLikeTypeTraits<To>::getFromVoidPointer(F.Val.getPointer());
>> }
>> };
>>
>> and declared it as a friend of PointerUnion.
>
> Could you declare the CastInfo struct itself as a friend? something like `template<typename To, typename...PTs> friend struct CastInfo<To, PointerUnion<PTs...>>`? That way you don't need the impl struct so it cuts down on overall code. Truly asking here - I think it's doable but I may be wrong.
It seems that partial specialization struct can't be declared as a friend.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125609/new/
https://reviews.llvm.org/D125609
More information about the llvm-commits
mailing list