#ifndef TYPEASVALUE_SRC_FUNCTION_DETAIL_APPLY_H_ #define TYPEASVALUE_SRC_FUNCTION_DETAIL_APPLY_H_ #include #include "list/list.h" #include "list/operation/nth.h" #include "list/operation/higher/query.h" namespace tav { namespace detail { struct placeholder_tag { }; template using is_placeholder = tav::Boolean< std::is_base_of::value >; template struct placeholder : placeholder_tag { }; template < typename Partials, typename Argument > struct resolve_placeholder { typedef Argument type; }; template < typename Partials, int Index > struct resolve_placeholder> { typedef typename Nth, Partials>::type type; }; template using count_placeholders = Count< is_placeholder, typename List::type >; template < template class Function, typename... Arguments > struct apply_variadic { template using type = Function< typename resolve_placeholder< typename tav::List::type, Arguments >::type... >; }; template < template class Function, typename... Arguments > struct apply_single : apply_variadic { template using type = typename apply_variadic< Function, Arguments... >::template type; }; template < template class Function, typename... Arguments > struct apply_pair : apply_variadic { template using type = typename apply_variadic< Function, Arguments... >::template type; }; } } #endif // TYPEASVALUE_SRC_FUNCTION_DETAIL_APPLY_H_