File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,54 @@ using SymbolID = std::array<unsigned char, 20>;
34
34
*/
35
35
constexpr SymbolID const EmptySID = SymbolID();
36
36
37
+ /* * Like optional<SymbolID>
38
+ */
39
+ class OptionalSymbolID
40
+ {
41
+ SymbolID ID_{};
42
+
43
+ public:
44
+ using value_type = SymbolID;
45
+
46
+ constexpr OptionalSymbolID () = default;
47
+
48
+ constexpr OptionalSymbolID (std::nullopt_t ) noexcept
49
+ : OptionalSymbolID()
50
+ {
51
+ }
52
+
53
+ constexpr OptionalSymbolID (
54
+ OptionalSymbolID const & other) = default;
55
+
56
+ constexpr OptionalSymbolID& operator =(
57
+ OptionalSymbolID const & other) = default ;
58
+
59
+ constexpr OptionalSymbolID (value_type const & v) noexcept
60
+ : ID_(v)
61
+ {
62
+ }
63
+
64
+ constexpr value_type& operator *() noexcept
65
+ {
66
+ return ID_;
67
+ }
68
+
69
+ constexpr value_type const & operator *() const noexcept
70
+ {
71
+ return ID_;
72
+ }
73
+
74
+ constexpr explicit operator bool () const noexcept
75
+ {
76
+ return has_value ();
77
+ }
78
+
79
+ constexpr bool has_value () const noexcept
80
+ {
81
+ return ID_ != EmptySID;
82
+ }
83
+ };
84
+
37
85
/* * The ID of the global namespace.
38
86
*/
39
87
constexpr SymbolID const globalNamespaceID = EmptySID;
You can’t perform that action at this time.
0 commit comments