libstdc++: Consolidate duplicate metaprogramming utilities
authorJonathan Wakely <jwakely@redhat.com>
Thu, 4 Nov 2021 11:11:58 +0000 (11:11 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 4 Nov 2021 18:14:50 +0000 (18:14 +0000)
commitb57899f30f4325a6fe4c791cf01a6a8c94b4ae50
tree06adad1edae89f6727b2dec5fcaaac7d05ab80ab
parent09aab7e699dcbd79fd64959cf259567bdca94022
libstdc++: Consolidate duplicate metaprogramming utilities

Currently std::variant uses __index_of<T, Types...> to find the first
occurence of a type in a pack, and __exactly_once<T, Types...> to check
that there is no other occurrence.

We can reuse the __find_uniq_type_in_pack<T, Types...>() function for
both tasks, and remove the recursive templates used to implement
__index_of and __exactly_once.

libstdc++-v3/ChangeLog:

* include/bits/utility.h (__find_uniq_type_in_pack): Move
definition to here, ...
* include/std/tuple (__find_uniq_type_in_pack): ... from here.
* include/std/variant (__detail__variant::__index_of): Remove.
(__detail::__variant::__exactly_once): Define using
__find_uniq_type_in_pack instead of __index_of.
(get<T>, get_if<T>, variant::__index_of): Likewise.
libstdc++-v3/include/bits/utility.h
libstdc++-v3/include/std/tuple
libstdc++-v3/include/std/variant