https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100157

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to m.cencora from comment #2)
> Please consider also adding a builtin for fetching index of type in type
> list.

I am already considering it and it's one of the reasons I don't like the name
"type pack element". That name isn't easily extensible to the reverse case.

I would prefer a pair of similar names involving "type at index" and "index of
type" or something like that. Or "index to type" and "tpe to index".

> While there are some easy implementations (like following), they are still
> not very performant.

The uses in the standard library also require an error if the type occurs more
than once, which yours doesn't check. I intend to add a built-in that supports
both cases with a boolean flag to say whether to fail if the type is repeated.

FWIW I think __find_uniq_type_in_pack() in libstdc++'s <bits/utility.h> scales
better than yours (and checks for uniqueness).

Reply via email to