libbio
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
bio::Pointer< T > Class Template Reference

#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)
 
Pointeroperator= (T *raw)
 
template<typename U >
type::EnableIf< pointer_detail::IsPointerConvertible< U, T >::sValue, Pointer & >::Type operator= (const Pointer< U > &other)
 
 operator T* () const
 
Toperator-> () const
 
Toperator* () const
 
TGet () 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
 

Detailed Description

template<typename T>
class bio::Pointer< T >

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.

Template Parameters
Tthe (non-owned) pointee type.

Member Typedef Documentation

◆ Type

template<typename T >
typedef T bio::Pointer< T >::Type

Constructor & Destructor Documentation

◆ Pointer() [1/3]

template<typename T >
bio::Pointer< T >::Pointer ( )
inline

Null, like a default-initialized raw pointer left dangling-but-zeroed.

◆ Pointer() [2/3]

template<typename T >
bio::Pointer< T >::Pointer ( T raw)
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.

Parameters
rawthe pointer to view (may be NULL / 0 / nullptr).

◆ Pointer() [3/3]

template<typename T >
template<typename U >
bio::Pointer< T >::Pointer ( const Pointer< U > &  other,
typename type::EnableIf< pointer_detail::IsPointerConvertible< U, T >::sValue, int >::Type  = 0 
)
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).

Template Parameters
Uthe source pointee type.
Parameters
otherthe convertible Pointer.

Member Function Documentation

◆ Get()

template<typename T >
T * bio::Pointer< T >::Get ( ) const
inline

Explicit accessor (parallels CowPtr::View / raw .get()). Also used by the upcast ctor to read a sibling's raw pointer.

Returns
the wrapped pointer.

◆ operator T*()

template<typename T >
bio::Pointer< T >::operator T* ( ) const
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".

Returns
the wrapped pointer.

◆ operator!=() [1/3]

template<typename T >
bool bio::Pointer< T >::operator!= ( const Pointer< T > &  other) const
inline
Parameters
otheranother Pointer< T >.
Returns
whether the two view different addresses.

◆ operator!=() [2/3]

template<typename T >
template<typename U >
bool bio::Pointer< T >::operator!= ( const Pointer< U > &  other) const
inline

◆ operator!=() [3/3]

template<typename T >
bool bio::Pointer< T >::operator!= ( T raw) const
inline
Parameters
rawa raw T*.
Returns
whether *this does not view raw.

◆ operator*()

template<typename T >
T & bio::Pointer< T >::operator* ( ) const
inline

Dereference the pointee, exactly like *(T*).

Returns
a reference to the pointee.

◆ operator->()

template<typename T >
T * bio::Pointer< T >::operator-> ( ) const
inline

Member access on the pointee, exactly like (T*)->member.

Returns
the wrapped pointer.

◆ operator<()

template<typename T >
bool bio::Pointer< T >::operator< ( const Pointer< T > &  other) const
inline

Ordering by viewed address for associative containers that used raw object pointers as keys before the Pointer migration.

Parameters
otheranother Pointer< T >.
Returns
whether this viewed address sorts before other's.

◆ operator=() [1/2]

template<typename T >
template<typename U >
type::EnableIf< pointer_detail::IsPointerConvertible< U, T >::sValue, Pointer & >::Type bio::Pointer< T >::operator= ( const Pointer< U > &  other)
inline

Re-seat from a convertible Pointer, matching raw-pointer assignment (Derived* -> Base*, T* -> const T*, etc.).

Template Parameters
Uthe source pointee type.
Parameters
otherthe new pointer view.
Returns
*this.

◆ operator=() [2/2]

template<typename T >
Pointer & bio::Pointer< T >::operator= ( T raw)
inline

Re-seat from a raw T*, like raw-pointer assignment.

Parameters
rawthe new pointer (may be NULL).
Returns
*this.

◆ operator==() [1/3]

template<typename T >
bool bio::Pointer< T >::operator== ( const Pointer< T > &  other) const
inline
Parameters
otheranother Pointer< T >.
Returns
whether both view the same address.

◆ operator==() [2/3]

template<typename T >
template<typename U >
bool bio::Pointer< T >::operator== ( const Pointer< U > &  other) const
inline

◆ operator==() [3/3]

template<typename T >
bool bio::Pointer< T >::operator== ( T raw) const
inline
Parameters
rawa raw T*.
Returns
whether *this views raw.

The documentation for this class was generated from the following file: