File Coverage

/usr/local/lib/perl5/site_perl/5.26.1/x86_64-linux/XS/libpanda.x/i/panda/function.h
Criterion Covered Total %
statement 8 10 80.0
branch n/a
condition n/a
subroutine n/a
pod n/a
total 8 10 80.0


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 70           class function {
13             public:
14             using Func = iptr>;
15             Func func;
16              
17             public:
18 0           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 8           function(F&&... f)
28 8           : func(function_details::make_abstract_function(std::forward(f)...))
29 8           {}
30              
31 38           function(Func func) : func(func) {};
32              
33 0           function(const function& oth) = default;
34             function(function&& oth) = default;
35              
36             function& operator=(const function& oth) = default;
37             function& operator=(function&& oth) = default;
38              
39 52           Ret operator ()(Args... args) const {return func->operator ()(std::forward(args)...);}
40              
41             template
42             typename = typename std::enable_if, function>::value>::type>
43             bool operator ==(const function& oth) const {
44             return (!func && !oth.func) || (func && oth && func->equals(oth.func.get()));
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             bool operator ==(const Ifunction& oth) const {
52             return func && func->equals(&oth);
53             }
54             bool operator !=(const Ifunction& oth) const {return !operator ==(oth);}
55              
56             explicit operator bool() const {
57             return func;
58             }
59             };
60              
61             template
62 70           class function : public function{
63             public:
64 54           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