35 template<
typename T,
typename SMART >
40 SMART
const &smart()
const noexcept {
return *
this; }
42 void _delete() noexcept
47 Cap<T> release()
const noexcept
72 template<
typename O >
74 { T* __t = ((O*)100); (void)__t; }
76 template<
typename O >
79 { T* __t = ((O*)100); (void)__t; }
81 template<
typename O >
82 Smart_cap(Smart_cap<O, SMART>
const &o) noexcept
83 :
Cap_base(SMART::copy(o)), SMART(o.smart())
84 { T* __t = ((O*)100); (void)__t; }
86 Smart_cap(Smart_cap
const &o) noexcept
87 :
Cap_base(SMART::copy(o)), SMART(o.smart())
90 template<
typename O >
92 { T* __t = ((O*)100); (void)__t; }
100 template<
typename O >
101 void operator = (Smart_cap<O, SMART>
const &o) noexcept
104 _c = this->SMART::copy(o).cap();
105 this->SMART::operator = (o.smart());
109 Smart_cap
const &operator = (Smart_cap
const &o) noexcept
115 _c = this->SMART::copy(o).cap();
116 this->SMART::operator = (o.smart());
120 #if __cplusplus >= 201103L
121 template<
typename O >
122 Smart_cap(Smart_cap<O, SMART> &&o) noexcept
123 :
Cap_base(o.release()), SMART(o.smart())
124 { T* __t = ((O*)100); (void)__t; }
126 Smart_cap(Smart_cap &&o) noexcept
127 :
Cap_base(o.release()), SMART(o.smart())
130 template<
typename O >
131 void operator = (Smart_cap<O, SMART> &&o) noexcept
134 _c = o.release().cap();
135 this->SMART::operator = (o.smart());
139 Smart_cap
const &operator = (Smart_cap &&o) noexcept
145 _c = o.release().cap();
146 this->SMART::operator = (o.smart());
158 ~Smart_cap() noexcept { _delete(); }
161 template<
typename T >
162 class Weak_cap :
public Cap_base
165 Weak_cap() noexcept : Cap_base(Invalid) {}
167 template<
typename O >
169 { T* __t = ((O*)100); (void)__t; }
171 template<
typename O,
typename S >
172 Weak_cap(Smart_cap<O, S>
const &c) noexcept :
Cap_base(c.cap())
173 { T* __t = ((O*)100); (void)__t; }
175 Weak_cap(Weak_cap
const &o) noexcept :
Cap_base(o) {}
177 template<
typename O >
178 Weak_cap(Weak_cap<O>
const &o) noexcept :
Cap_base(o)
179 { T* __t = ((O*)100); (void)__t; }
183 namespace Cap_traits {
184 template<
typename T1,
typename T2 >
185 struct Type {
enum { Equal =
false }; };
187 template<
typename T1 >
188 struct Type<T1,T1> {
enum { Equal =
true }; };
201 template<
typename T,
typename F,
typename SMART >
205 (void)
static_cast<T
const *
>(
reinterpret_cast<F
const *
>(100));
220 template<
typename T,
typename F,
typename SMART >
L4::Cap related definitions.
Base class for all kinds of capabilities.
l4_cap_idx_t _c
The C representation of a capability selector.
l4_cap_idx_t cap() const noexcept
Return capability selector.
Cap_type
Invalid capability type.
@ Invalid
Invalid capability selector.
Cap_base(l4_cap_idx_t c) noexcept
Generate a capability from its C representation.
Cap_base() noexcept
Create an uninitialized instance.
C++ interface for capabilities.
Cap< T > operator->() const noexcept
Member access of a T.
Smart_cap(Cap< O > const &p) noexcept
Internal constructor, use to generate a capability from a this pointer.
unsigned long l4_cap_idx_t
L4 Capability selector Type.
@ L4_INVALID_CAP
Invalid capability selector.
L4 low-level kernel interface.
Cap< T > cap_reinterpret_cast(Cap< F > const &c) noexcept
reinterpret_cast for capabilities.
Cap< T > cap_cast(Cap< F > const &c) noexcept
static_cast for capabilities.