line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#pragma once |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#if __cpp_lib_optional >= 201603L |
4
|
|
|
|
|
|
|
# include |
5
|
|
|
|
|
|
|
namespace panda { |
6
|
|
|
|
|
|
|
template |
7
|
|
|
|
|
|
|
using optional = std::optional; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
#else |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
namespace panda { |
12
|
|
|
|
|
|
|
template |
13
|
|
|
|
|
|
|
struct optional { |
14
|
6
|
|
|
|
|
|
optional() : exists(false) {} |
15
|
1
|
|
|
|
|
|
optional(const T& val) :val(val), exists(true) {} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
T value() const { |
18
|
|
|
|
|
|
|
return val; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
T value_or(const T& def) const { |
22
|
0
|
0
|
|
|
|
|
return exists ? val : def; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
explicit operator bool() const { |
26
|
|
|
|
|
|
|
return exists; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
T val; |
30
|
|
|
|
|
|
|
bool exists; |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
template |
34
|
|
|
|
|
|
|
struct optional_tools { |
35
|
|
|
|
|
|
|
using type = optional; |
36
|
12
|
|
|
|
|
|
static type default_value() {return type{};} |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
template <> |
40
|
|
|
|
|
|
|
struct optional_tools { |
41
|
|
|
|
|
|
|
static void default_value(){} |
42
|
|
|
|
|
|
|
using type = void; |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#endif |
47
|
|
|
|
|
|
|
|