xieite ::fold <>
Defined in header <xieite/meta/fold.hpp>
A utility for turning recursive function calls into a single fold expression whenever the number of iterations is known beforehand.
Definition
template <auto fn ,typename T ,typename... Ts >using fold =/* ??? */ ;
Example
[View in Compiler Explorer]template <typename... Ts >struct type_list {template <typename T >static constexpr bool has = (... ||std ::same_as <Ts ,T >);template <typename T >using append =type_list <Ts ...,T >;template <template <typename... >typename M >using to =M <Ts ...>; };template <typename... Ts >using unique_variant =xieite ::fold < []<typename List ,typename T >static {if constexpr (!List ::template has <T >) {return typename List ::template append <T >(); }else {return List (); } },type_list <>,Ts ... >::template to <std ::variant >;static_assert (std ::same_as <unique_variant <int ,int ,char ,int ,float ,char >,std ::variant <int ,char ,float > >);