|
libbio
|
#include <Pointer.h>
Public Types | |
| typedef T | Type |
Public Member Functions | |
| Pointer () | |
| Pointer (T *raw) | |
| template<typename U > | |
| Pointer (const Pointer< U > &other, typename type::EnableIf< pointer_detail::IsPointerConvertible< U, T >::sValue, int >::Type=0) | |
| Pointer & | operator= (T *raw) |
| template<typename U > | |
| type::EnableIf< pointer_detail::IsPointerConvertible< U, T >::sValue, Pointer & >::Type | operator= (const Pointer< U > &other) |
| operator T* () const | |
| T * | operator-> () const |
| T & | operator* () const |
| T * | Get () const |
| bool | operator== (const Pointer &other) const |
| template<typename U > | |
| bool | operator== (const Pointer< U > &other) const |
| bool | operator!= (const Pointer &other) const |
| template<typename U > | |
| bool | operator!= (const Pointer< U > &other) const |
| bool | operator== (T *raw) const |
| bool | operator!= (T *raw) const |
| bool | operator< (const Pointer &other) const |
Pointer< T > — a transparent default wrapper around a raw T*.
PHASE 0 of a staged refactor (lib/bio/docs/RFC_POINTER_TYPE.md): this class is a drop-in, behavior-identical, SAME-SIZE (one pointer) stand-in for a bare T*. There is NO arena, NO size change and NO behavior change here — the entire point of this phase is a wrapper provably indistinguishable from a raw pointer so that a later, purely mechanical T* -> Pointer< T > member swap can be verified as a behavioral no-op. Later phases may add generation/UAF tooling BEHIND this same one-pointer footprint. At BIO_MEMORY_OPTIMIZE_LEVEL >= 2, the internal compact-pointer path stores a 32-bit arena handle instead, so it is intentionally NOT part of the default ABI/layout guarantee. In that mode, pointers to pointer_arena storage resolve as base + ((handle - 1) << 3); non-arena raw pointers take a compatibility foreign-handle path.
Sibling of the existing wrapper family but DELIBERATELY un-unified with it:
LAYOUT GUARANTEE (load-bearing): in normal builds this has exactly one T* member, no vtable, and defaulted special members. sizeof(Pointer< T >) == sizeof(T*), and Pointer< T > is standard-layout + trivially-copyable. In level-2 compact-pointer builds, the single member is a 32-bit handle. The static_asserts below pin both layouts on cpp11+; the whole refactor depends on it. Because it is trivially-copyable it is also trivially-RELOCATABLE: it is wired into type::IsMemcpySafe (see the specialization at the bottom of this file) so Arrangement< Pointer< X > > selects its memcpy/realloc specialization and relocates *this on Expand() byte-for-byte.
| T | the (non-owned) pointee type. |
|
inline |
Null, like a default-initialized raw pointer left dangling-but-zeroed.
|
inline |
Implicit wrap of a raw T* — Pointer< T > p = somePtr; just works, exactly like assigning one raw pointer to another. Intentionally non-explicit so the wrapper is a drop-in for a bare T*.
This single ctor also covers NULL, the literal 0 and (cpp11+) nullptr: each is a null-pointer constant that binds here directly. A dedicated std::nullptr_t ctor is intentionally OMITTED because it would make Pointer< T >(NULL) / Pointer< T >(0) AMBIGUOUS (the integer-literal 0 converts equally well to T* and to nullptr_t) — verified at build time.
| raw | the pointer to view (may be NULL / 0 / nullptr). |
|
inline |
Polymorphic / qualification upcast: Pointer< Derived > -> Pointer< Base >, Pointer< T > -> Pointer< const T >, Pointer< T > -> Pointer< void >, etc. Enabled ONLY when a U* implicitly converts to a T* — i.e. precisely when the bare pointers would convert — so this is a true no-op stand-in for raw pointer conversions and never opens an unsafe downcast. Uses libbio's own EnableIf + the cpp98-safe convertibility trait above (NOT std::is_convertible / IsBaseOf, which are unavailable / inert on cpp98).
| U | the source pointee type. |
| other | the convertible Pointer. |
|
inline |
Explicit accessor (parallels CowPtr::View / raw .get()). Also used by the upcast ctor to read a sibling's raw pointer.
|
inline |
Transparent decay to the raw T* — lets a Pointer< T > be passed wherever a T* is expected, the heart of "indistinguishable from a raw pointer".
|
inline |
| other | another Pointer< T >. |
|
inline |
|
inline |
| raw | a raw T*. |
|
inline |
Dereference the pointee, exactly like *(T*).
|
inline |
Member access on the pointee, exactly like (T*)->member.
|
inline |
Ordering by viewed address for associative containers that used raw object pointers as keys before the Pointer migration.
| other | another Pointer< T >. |
|
inline |
Re-seat from a convertible Pointer, matching raw-pointer assignment (Derived* -> Base*, T* -> const T*, etc.).
| U | the source pointee type. |
| other | the new pointer view. |
|
inline |
Re-seat from a raw T*, like raw-pointer assignment.
| raw | the new pointer (may be NULL). |
|
inline |
| other | another Pointer< T >. |
|
inline |
|
inline |
| raw | a raw T*. |