cptr::basic_ptr::basic_ptr

Constructors

Synopses

Declared in <cptr/ptr.hpp>

Null.

constexpr
basic_ptr() noexcept = default;
» more...

Converts from a pointer to U where U* converts implicitly to T*: adding cv-qualifiers, to void, or derived to base. Only the derived-to-base case at a non-zero offset decompresses; the others copy the offset.

template<
    class U,
    bool S>
requires std::is_convertible_v<U*, T*>
constexpr
explicit(Strict && !S)
basic_ptr(basic_ptr<U, Cage, S> const& other) noexcept;
» more...

The same explicit casts from another compressed pointer. From void the offset is copied (and this is constexpr); base to derived goes through a raw pointer, except for null.

template<
    class U,
    bool S>
requires (!std::is_convertible_v<U*, T*> &&
             requires(U* u) { static_cast<T*>(u); })
constexpr
explicit
basic_ptr(basic_ptr<U, Cage, S> const& other) noexcept;
» more...

Null, from a literal 0 or NULL, which older code and some fancy pointer users (plf::list) write for null pointers. Like a raw pointer, it accepts only a null pointer constant: an integer variable, a non-zero literal or a bool does not convert.

constexpr
basic_ptr(detail::null_literal value) noexcept;
» more...

Null.

template<class N>
requires std::is_null_pointer_v<N>
constexpr
basic_ptr(N value) noexcept;
» more...

Compresses p, which must be null or point into the cage. Implicit for ptr, explicit for strict_ptr. A template on U only so that a literal 0 picks the constructor above instead of being ambiguous; it takes any U* that converts implicitly to T*.

template<class U>
requires std::is_convertible_v<U*, T*>
explicit(Strict)
basic_ptr(U* p) noexcept;
» more...

Explicit casts that static_cast allows, such as base to derived or void* to T*.

template<class U>
requires (!std::is_convertible_v<U*, T*> &&
             requires(U* u) { static_cast<T*>(u); })
explicit
basic_ptr(U* p) noexcept;
» more...