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