nngn
Loading...
Searching...
No Matches
fn.h
Go to the documentation of this file.
1#ifndef NNGN_UTILS_FN_H
2#define NNGN_UTILS_FN_H
3
4#include <tuple>
5
6#include "types.h"
7#include "utils.h"
8
9namespace nngn {
10
11namespace detail {
12
13template<typename T> struct fn_args;
14
15template<typename R, typename ...A>
16struct fn_args<R(*)(A...)> { using type = types<A...>; };
17
18}
19
20template<auto f>
21using fn_args = typename detail::fn_args<decltype(f)>::type;
22
24template<typename T>
25struct to {
26 constexpr T operator()(auto &&x) const { return static_cast<T>(FWD(x)); }
27};
28
30template<auto x>
31struct constant {
32 constexpr auto operator()(auto&&...) const { return x; }
33};
34
35}
36
37#endif
function f()) end
#define FWD(...)
Definition: utils.h:18
#define T(f0, f1, f2)
Definition: audio.cpp:7
typename detail::fn_args<>::type fn_args
Definition: fn.h:21
constexpr auto operator()(auto &&...) const
Definition: fn.h:32
Definition: fn.h:13
Definition: types.h:32
Function object which converts its argument to T via static_cast.
Definition: fn.h:25
constexpr T operator()(auto &&x) const
Definition: fn.h:26