aboutsummaryrefslogtreecommitdiff
path: root/src/function/detail/placeholder.h
blob: 8105de566c5f4822bc831c5a1710e60a3c27f639 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef TYPEASVALUE_SRC_FUNCTION_DETAIL_PLACEHOLDER_H_
#define TYPEASVALUE_SRC_FUNCTION_DETAIL_PLACEHOLDER_H_

#include <type_traits>

#include "list/list.h"
#include "list/operation/nth.h"
#include "list/operation/higher/query.h"

namespace tav {

namespace detail {

struct placeholder_tag { };

template <int Index>
struct placeholder : placeholder_tag { };

template <typename Type>
using is_placeholder = Eval<std::is_base_of<placeholder_tag, Type>>;

template <typename... Arguments>
using count_placeholders = Count<is_placeholder, List<Arguments...>>;

template <typename, typename Argument>
struct resolve_placeholder {
	typedef Argument type;
};

template <
	typename Partials,
	int      Index
>
struct resolve_placeholder<Partials, placeholder<Index>> {
	typedef Nth<Size<Index>, Partials> type;
};

}

}

#endif  // TYPEASVALUE_SRC_FUNCTION_DETAIL_PLACEHOLDER_H_