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