A `std::shared_ptr ` value.
| 374 | # are stable), before falling back on calling the public API methods. |
| 375 | |
| 376 | class SharedPtr: |
| 377 | """ |
| 378 | A `std::shared_ptr<T>` value. |
| 379 | """ |
| 380 | |
| 381 | def __init__(self, val): |
| 382 | self.val = val |
| 383 | try: |
| 384 | # libstdc++ internals |
| 385 | self._ptr = val['_M_ptr'] |
| 386 | except gdb.error: |
| 387 | # fallback for other C++ standard libraries |
| 388 | self._ptr = gdb.parse_and_eval(f"{for_evaluation(val)}.get()") |
| 389 | |
| 390 | def get(self): |
| 391 | """ |
| 392 | Return the underlying pointer (a T*). |
| 393 | """ |
| 394 | return self._ptr |
| 395 | |
| 396 | @property |
| 397 | def value(self): |
| 398 | """ |
| 399 | The underlying value (a T). |
| 400 | """ |
| 401 | return self._ptr.dereference() |
| 402 | |
| 403 | |
| 404 | class UniquePtr: |