diff --git a/include/fc/reflect/typelist.hpp b/include/fc/reflect/typelist.hpp index d1d3e0d7a..f7f67bc43 100644 --- a/include/fc/reflect/typelist.hpp +++ b/include/fc/reflect/typelist.hpp @@ -128,6 +128,20 @@ struct zip, list> { using type = typename concat>, typename zip, list>::type>::type; }; +template class> struct any; +template class Predicate> +struct any, Predicate> { + constexpr static bool value = false; +}; +template class Predicate> +struct any, Predicate> { + constexpr static bool value = Predicate::value; +}; +template class Predicate> +struct any, Predicate> { + constexpr static bool value = Predicate::value || any, Predicate>::value; +}; + template Ret dispatch_helper(Callable& c) { return c(T()); } @@ -224,6 +238,17 @@ using zip = typename impl::zip::type; template using index = typename impl::zip()>::type, List>::type; +/// Determine whether any type in list passes predicate +template class Predicate> +constexpr static bool any = impl::any::value; + +/// A wrapper which wraps an uninstantiated template in a type so it can be handled in a typelist +template class Template> +struct wrapped { + template + using unwrap = Template; +}; + /// This namespace contains some utilities that provide runtime operations on typelists namespace runtime { /// Type wrapper object allowing arbitrary types to be passed to functions as information rather than data