summaryrefslogtreecommitdiff
path: root/indra/llcommon/function_types.h
blob: 7e15895a7e69d1ed3c93100289a7b18a31cef827 (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
43
44
45
46
47
48
49
/**
 * @file   function_types.h
 * @author Nat Goodspeed
 * @date   2023-01-20
 * @brief  Extend boost::function_types to examine boost::function and
 *         std::function
 *
 * $LicenseInfo:firstyear=2023&license=viewerlgpl$
 * Copyright (c) 2023, Linden Research, Inc.
 * $/LicenseInfo$
 */

#if ! defined(LL_FUNCTION_TYPES_H)
#define LL_FUNCTION_TYPES_H

#include <boost/function.hpp>
#include <boost/function_types/function_arity.hpp>
#include <functional>

namespace LL
{

    template <typename F>
    struct function_arity_impl
    {
        static constexpr auto value = boost::function_types::function_arity<F>::value;
    };

    template <typename F>
    struct function_arity_impl<std::function<F>>
    {
        static constexpr auto value = function_arity_impl<F>::value;
    };

    template <typename F>
    struct function_arity_impl<boost::function<F>>
    {
        static constexpr auto value = function_arity_impl<F>::value;
    };

    template <typename F>
    struct function_arity
    {
        static constexpr auto value = function_arity_impl<typename std::decay<F>::type>::value;
    };

} // namespace LL

#endif /* ! defined(LL_FUNCTION_TYPES_H) */