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