DocWire SDK
DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, document analysis. Offline processing possible for security and confidentiality
docwire::not_null< Ptr, safety_level > Class Template Reference

A wrapper for pointer-like types that enforces a non-null invariant. More...

#include <not_null.h>

Public Member Functions

 not_null (Ptr p)
 Constructs from a pointer, enforcing the non-null invariant in strict mode.
 
 not_null (Ptr p, guaranteed_t)
 Unchecked constructor for when the pointer is guaranteed to be non-null. This is an optimization to avoid redundant checks, e.g., after std::make_shared.
 
template<typename... Args, typename = std::enable_if_t<std::is_constructible_v<Ptr, Args...> && (sizeof...(Args) > 1)>>
 not_null (Args &&... args)
 
 not_null (std::nullptr_t)=delete
 
not_nulloperator= (std::nullptr_t)=delete
 
auto get () const requires requires(const Ptr &p)
 Returns the raw pointer.
 
auto get () requires requires(Ptr &p)
 
auto & operator* () const
 
auto & operator* ()
 
auto operator-> () const
 
auto operator-> ()
 
 operator const Ptr & () const
 

Detailed Description

template<typename Ptr, safety_policy safety_level = default_safety_level>
class docwire::not_null< Ptr, safety_level >

A wrapper for pointer-like types that enforces a non-null invariant.

In strict mode, the constructor checks for null and throws if the invariant is violated. In relaxed mode, this wrapper is a zero-cost abstraction with no runtime checks.

Template Parameters
PtrThe underlying pointer type.
safety_levelThe safety policy to apply.
See also
checked

Definition at line 40 of file not_null.h.


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