jwakely added a comment.

In D151952#4396485 <https://reviews.llvm.org/D151952#4396485>, @cjdb wrote:

> Since we're doing this, it may also be worth checking that `T1s...` are 
> unique in `T2s...`, which I'd intended to be a separate feature.

It seems like it would be more efficient to include the uniqueness check in the 
intrinsic, otherwise `std::get<T>` and helpers like libstdc++'s 
`variant::__index_of<T>` will still need some template metaprogramming to check 
for uniqueness. Even if there's a separate intrinsic for that, it seems more 
useful to just have one intrinsic that does both. If you have a use case for 
finding the index of the first T in a pack, maybe add an additional boolean 
that requests uniqueness and would cause `__type_pack_index` to fail if T is 
not unique.

As @BertalanD also said, it doesn't seem useful to be ill-formed if the type 
isn't in the pack. That makes it unusable for `std::get<T>` and `std::variant`. 
Libstdc++'s `__find_uniq_type_in_pack<T, Types...>` returns `sizeof...(Types)` 
if `T` isn't found (either this or `-1uz` seems fine, you can check the 
returned index is `< sizeof...(Types)` to tell if the type was found).



================
Comment at: clang/docs/LanguageExtensions.rst:1660
+    T& get(tuple<Ts...>& ts) noexcept {
+      return std::get<__type_pack_index(T, Ts...)>(ts);
+    }
----------------
If this intrinsic doesn't (yet?) check for uniqueness, then this `get<T>` 
doesn't match `std::get<T>`. It might be worth mentioning that here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151952

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D151952: [clang] a... Daniel Bertalan via Phabricator via cfe-commits
    • [PATCH] D151952: [cla... Jonathan Wakely via Phabricator via cfe-commits

Reply via email to