1
#ifndef CHILON_ARGUMENT_HPP
2
#define CHILON_ARGUMENT_HPP
3
4
#include <chilon/meta/return.hpp>
5
#include <chilon/meta/at.hpp>
6
7
namespace chilon {
8
9
namespace detail {
10
    template <int I, class R>
11
    struct argument {
12
        template <class H, class... T>
13
        static R exec(H&& h, T&&... t) {
14
            return argument<I - 1, R>::exec(t...);
15
        }
16
    };
17
18
    template <class R>
19
    struct argument<0, R> {
20
        template <class H, class... T>
21
        static R exec(H&& h, T&&... t) {
22
            return h;
23
        }
24
    };
25
}
26
27
template <int I, class... T>
28
auto argument(T&&... t) CHILON_RETURN(
29
    detail::argument<
30
        I, typename meta::at<I, T...>::type &>::exec(std::forward<T>(t)...))
31
32
template <int I, class U, class... T>
33
auto argument_default(U&& u, T&&... t) CHILON_RETURN(
34
    detail::argument<
35
        I, typename meta::at<I, T...>::type &>::exec(std::forward<T>(t)...))
36
37
template <int I, class U, class... T>
38
auto argument_default(U&& u, T&&... t) CHILON_RETURN(std::forward<U>(u))
39
40
}
41
#endif