summaryrefslogtreecommitdiff
path: root/include/SSVOpenHexagon/Utils/ArgExtractor.hpp
blob: 43257d1e988042d236ef23a97887d75932728a86 (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
// Copyright (c) 2013-2020 Vittorio Romeo
// License: Academic Free License ("AFL") v. 3.0
// AFL License page: https://opensource.org/licenses/AFL-3.0

#pragma once

#include <cstddef>
#include <tuple>

namespace hg::Utils {

template <typename>
struct ArgExtractor;

template <typename R, typename F, typename... Args>
struct ArgExtractor<R (F::*)(Args...)>
{
    using Return = R;
    using Function = F;

    inline static constexpr std::size_t numArgs = sizeof...(Args);

    template <std::size_t I>
    using NthArg = std::tuple_element_t<I, std::tuple<Args...>>;
};

template <typename R, typename F, typename... Args>
struct ArgExtractor<R (F::*)(Args...) const>
{
    using Return = R;
    using Function = F;

    inline static constexpr std::size_t numArgs = sizeof...(Args);

    template <std::size_t I>
    using NthArg = std::tuple_element_t<I, std::tuple<Args...>>;
};

} // namespace hg::Utils