capydi
Loading...
Searching...
No Matches
Functor.hpp
Go to the documentation of this file.
1#ifndef META_FUNCTION_HPP_
2#define META_FUNCTION_HPP_
3
8
9#include <array>
10#include <functional>
11
12namespace capy::meta
13{
14
15template<
16 auto Functor_,
17 MetaArity REQUIRED_ARITY,
18 MetaArity... OPTIONAL_ARITIES
19>
21{
22public:
23 static constexpr std::array META_CALLABLE_TAGS = {
25 };
26
27 static constexpr std::array META_CALLABLE_ARITIES = {
28 REQUIRED_ARITY,
29 OPTIONAL_ARITIES...
30 };
31
32public:
33 template<typename... Args>
34 requires std::invocable<decltype(Functor_), Pack<Args...>>
35 struct Functor
36 {
37 public:
38 using type = std::invoke_result_t<decltype(Functor_), Pack<Args...>>;
39 };
40
41public:
42 template<MetaArity ARITY>
44
46};
47
48template<
49 auto Functor_,
50 MetaArity REQUIRED_ARITY,
51 MetaArity... OPTIONAL_ARITIES
52>
54{
55public:
60
61 static constexpr std::array META_CALLABLE_ARITIES = {
62 REQUIRED_ARITY,
63 OPTIONAL_ARITIES...
64 };
65
66public:
67 template<typename... Args>
68 requires std::invocable<decltype(Functor_), Pack<Args...>>
69 struct Functor
70 {
71 private:
72 using ReturnType = std::invoke_result_t<decltype(Functor_), Pack<Args...>>;
73
74 public:
75 using type = ReturnType;
76
77 public:
78 static constexpr ReturnType value = std::invoke(
79 Functor_,
81 );
82 };
83
84public:
85 template<MetaArity ARITY>
87
89};
90
91}
92
93#endif // !META_FUNCTION_HPP_
Compile-time type pack utilities and metaprogramming foundations.
Definition Rebind.hpp:7
typename implementation_details_::FixTemplateArityValued< ARITY, Template > fix_template_arity_fv
Definition FixTemplateMetaArity.hpp:87
typename implementation_details_::FixTemplateArityTyped< ARITY, Template > fix_template_arity_ft
Definition FixTemplateMetaArity.hpp:81
MetaArity
Definition MetaArity.hpp:11
@ VALUE_CALLABLE
Definition Trait.hpp:15
@ TYPE_CALLABLE
Definition Trait.hpp:14
A compile-time heterogeneous type list.
Definition Pack.hpp:70
Definition Functor.hpp:36
std::invoke_result_t< decltype(Functor_), Pack< Args... > > type
Definition Functor.hpp:38
Definition Functor.hpp:21
static constexpr std::array META_CALLABLE_ARITIES
Definition Functor.hpp:27
fix_template_arity_ft< ARITY, Functor > as_nary
Definition Functor.hpp:43
static constexpr std::array META_CALLABLE_TAGS
Definition Functor.hpp:23
as_nary< MetaArity::N1 > as_unary
Definition Functor.hpp:45
Definition Functor.hpp:70
static constexpr ReturnType value
Definition Functor.hpp:78
ReturnType type
Definition Functor.hpp:75
Definition Functor.hpp:54
static constexpr std::array META_CALLABLE_ARITIES
Definition Functor.hpp:61
as_nary< MetaArity::N1 > as_unary
Definition Functor.hpp:88
fix_template_arity_fv< ARITY, Functor > as_nary
Definition Functor.hpp:86
static constexpr std::array META_CALLABLE_TAGS
Definition Functor.hpp:56