cptr::nonnull_ptr

Like ptr, but never null, which makes decompression a single add.

Synopsis

Declared in <cptr/ptr.hpp>

template<
    class T,
    class Cage = default_cage>
class nonnull_ptr;

Description

It converts implicitly to ptr and strict_ptr (to the same type, a base or void), and to a nonnull_ptr to a base. destroy() accepts it.

Type Aliases

NameDescription
cage_type The cage the pointer is compressed against.
element_type The type pointed to.

Member Functions

NameDescription
nonnull_ptr [constructor]Constructors
bits The compressed representation, as for basic_ptr::bits(); never 0.
get The raw pointer: a single add, with no null check.
operator* The object pointed to.
operator-> Member access.
operator T* Converts implicitly to the raw pointer.
operator basic_ptr<U, Cage, S> Converts implicitly to a nullable ptr or strict_ptr to U, where T* converts implicitly to U*. The pointer is already in the cage, so strict_ptr accepts it implicitly too.

Static Member Functions

NameDescription
from_bits The pointer whose bits() are bits, which must not be 0 (that is null in a ptr) and must come from a pointer into the same cage; see basic_ptr::from_bits.

Friends

NameDescription
cptr::operator<=>Orders like the addresses.
cptr::operator==Same address.

Non-Member Functions

NameDescription
destroydestroy() for a nonnull_ptr.