aboutsummaryrefslogtreecommitdiff
path: root/src/function/apply.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/function/apply.h')
-rw-r--r--src/function/apply.h62
1 files changed, 11 insertions, 51 deletions
diff --git a/src/function/apply.h b/src/function/apply.h
index 8e780e0..21364a8 100644
--- a/src/function/apply.h
+++ b/src/function/apply.h
@@ -1,43 +1,12 @@
#ifndef TYPEASVALUE_SRC_FUNCTION_APPLY_H_
#define TYPEASVALUE_SRC_FUNCTION_APPLY_H_
-#include <type_traits>
+#include "conditional/if.h"
-#include "list/list.h"
-#include "list/operation/nth.h"
+#include "detail/apply.h"
namespace tav {
-namespace detail {
-
-struct placeholder_tag { };
-
-template <typename Type>
-using is_placeholder = tav::Boolean<
- std::is_base_of<placeholder_tag, Type>::value
->;
-
-template <int Index>
-struct placeholder : placeholder_tag { };
-
-template <
- typename Partials,
- typename Argument
->
-struct resolve_placeholder {
- typedef Argument type;
-};
-
-template <
- typename Partials,
- int Index
->
-struct resolve_placeholder<Partials, placeholder<Index>> {
- typedef typename Nth<Size<Index>, Partials>::type type;
-};
-
-}
-
typedef detail::placeholder<0> _0;
typedef detail::placeholder<1> _1;
typedef detail::placeholder<2> _2;
@@ -47,24 +16,15 @@ template <
template<typename...> class Function,
typename... Arguments
>
-struct Apply {
- template <typename... Partials>
- using variadic_type = Function<
- typename detail::resolve_placeholder<
- typename tav::List<Partials...>::type,
- Arguments
- >::type...
- >;
-
- template <typename Partial>
- using single_type = variadic_type<Partial>;
-
- template <typename Partial0, typename Partial1>
- using pair_type = variadic_type<Partial0, Partial1>;
-
- template <typename Partial0, typename Partial1, typename Partial2>
- using triple_type = variadic_type<Partial0, Partial1, Partial2>;
-};
+struct Apply : If<
+ (detail::count_placeholders<Arguments...>::type::value > 2),
+ detail::apply_variadic<Function, Arguments...>,
+ typename If<
+ detail::count_placeholders<Arguments...>::type::value == 2,
+ detail::apply_pair<Function, Arguments...>,
+ detail::apply_single<Function, Arguments...>
+ >::type
+>::type { };
}