A `std::unique_ptr ` value.
| 400 | |
| 401 | |
| 402 | class UniquePtr: |
| 403 | """ |
| 404 | A `std::unique_ptr<T>` value. |
| 405 | """ |
| 406 | |
| 407 | def __init__(self, val): |
| 408 | self.val = val |
| 409 | ty = self.val.type.template_argument(0) |
| 410 | # XXX This assumes that the embedded T* pointer lies at the start |
| 411 | # of std::unique_ptr<T>. |
| 412 | self._ptr = self.val.address.reinterpret_cast(ty.pointer().pointer()) |
| 413 | |
| 414 | def get(self): |
| 415 | """ |
| 416 | Return the underlying pointer (a T*). |
| 417 | """ |
| 418 | return self._ptr |
| 419 | |
| 420 | @property |
| 421 | def value(self): |
| 422 | """ |
| 423 | The underlying value (a T). |
| 424 | """ |
| 425 | return self._ptr.dereference() |
| 426 | |
| 427 | |
| 428 | class Variant: |