line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#pragma once |
2
|
|
|
|
|
|
|
#include "refcnt.h" |
3
|
|
|
|
|
|
|
#include "function_utils.h" |
4
|
|
|
|
|
|
|
#include |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
namespace panda { |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
template |
9
|
|
|
|
|
|
|
class function; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
template |
12
|
516
|
|
|
|
|
|
class function { |
13
|
|
|
|
|
|
|
public: |
14
|
|
|
|
|
|
|
using Func = iptr>; |
15
|
|
|
|
|
|
|
Func func; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
public: |
18
|
84
|
|
|
|
|
|
function(){} |
19
|
|
|
|
|
|
|
function(std::nullptr_t){} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
template |
22
|
|
|
|
|
|
|
function(const iptr& f) : func(f) {} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
template
|
25
|
|
|
|
|
|
|
typename = decltype(function_details::make_abstract_function(std::declval()...)), |
26
|
|
|
|
|
|
|
typename = typename std::enable_if::value>::type> |
27
|
41
|
|
|
|
|
|
function(F&&... f) |
28
|
41
|
|
|
|
|
|
: func(function_details::make_abstract_function(std::forward(f)...)) |
29
|
41
|
|
|
|
|
|
{} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
function(Func func) : func(func) {}; |
32
|
|
|
|
|
|
|
|
33
|
268
|
|
|
|
|
|
function(const function& oth) = default; |
34
|
52
|
|
|
|
|
|
function(function&& oth) = default; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
function& operator=(const function& oth) = default; |
37
|
|
|
|
|
|
|
function& operator=(function&& oth) = default; |
38
|
|
|
|
|
|
|
|
39
|
70
|
50
|
|
|
|
|
Ret operator ()(Args... args) const {return func->operator ()(std::forward(args)...);} |
|
|
0
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
template
|
42
|
|
|
|
|
|
|
typename = typename std::enable_if, function>::value>::type> |
43
|
8
|
|
|
|
|
|
bool operator ==(const function& oth) const { |
44
|
8
|
50
|
|
|
|
|
return (!func && !oth.func) || (func && oth && func->equals(oth.func.get())); |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
template
|
48
|
|
|
|
|
|
|
typename = typename std::enable_if, function>::value>::type> |
49
|
|
|
|
|
|
|
bool operator !=(const function& oth) const {return !operator ==(oth);} |
50
|
|
|
|
|
|
|
|
51
|
7
|
|
|
|
|
|
bool operator ==(const Ifunction& oth) const { |
52
|
7
|
50
|
|
|
|
|
return func && func->equals(&oth); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
bool operator !=(const Ifunction& oth) const {return !operator ==(oth);} |
55
|
|
|
|
|
|
|
|
56
|
97
|
|
|
|
|
|
explicit operator bool() const { |
57
|
97
|
|
|
|
|
|
return func; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
}; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
template |
62
|
920
|
|
|
|
|
|
class function : public function{ |
63
|
|
|
|
|
|
|
public: |
64
|
82
|
|
|
|
|
|
using function::function; |
65
|
|
|
|
|
|
|
using ArgsTuple = std::tuple; |
66
|
|
|
|
|
|
|
using RetType = Ret; |
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
template |
70
|
|
|
|
|
|
|
inline function make_function(Ret (Class::*meth)(Args...), iptr thiz = nullptr) { |
71
|
|
|
|
|
|
|
return function(meth, thiz); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
template |
75
|
|
|
|
|
|
|
inline function make_function(Ret (*f)(Args...)) { |
76
|
|
|
|
|
|
|
return function(f); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|