![]() |
Arene Base
Fundamental Utilities For Safety Critical C++
|
A pointer type which is never nullptr.
More...

Public Types | |
| using | element_type = typename std::pointer_traits<held_pointer>::element_type |
| The type of the element pointed to. | |
| using | held_pointer = P |
The pointer type being wrapped by the non_null . | |
Public Member Functions | |
| constexpr | non_null ()=delete |
non_null cannot be default constructed | |
| constexpr | non_null (non_null &&)=default |
| Default move constructor. | |
| constexpr | non_null (non_null const &)=default |
| Default copy constructor. | |
| template<typename U = held_pointer, constraints< std::enable_if_t< std::is_constructible< held_pointer, U && >::value > > = nullptr> | |
| constexpr | non_null (non_null< U > &&move_from) noexcept(std::is_nothrow_constructible< held_pointer, U && >::value) |
Move constructor from non_null. | |
| template<typename U = held_pointer, constraints< std::enable_if_t< std::is_constructible< held_pointer, U const & >::value > > = nullptr> | |
| constexpr | non_null (non_null< U > const ©_from) noexcept(std::is_nothrow_constructible< held_pointer, U const & >::value) |
Copy constructor from non_null. | |
| constexpr | non_null (std::nullptr_t)=delete |
non_null cannot be constructed from a literal nullptr . | |
| template<typename U, constraints< std::enable_if_t<!is_non_null_v< U >, std::enable_if_t< std::is_constructible< held_pointer, U >::value > > > = nullptr> | |
| constexpr | non_null (U &&ptr_value) noexcept(std::is_nothrow_constructible< held_pointer, U >::value) |
| Construction from a pointer type. | |
| ~non_null ()=default | |
| Default destructor. | |
| ARENE_NODISCARD constexpr auto | operator! () const noexcept -> bool |
Boolean negation operator, equivalent to a == comparison to nullptr. | |
| template<typename U = element_type, typename = std::enable_if_t<!std::is_same<std::remove_cv_t<U>, void>::value>> | |
| ARENE_NODISCARD constexpr auto | operator* () const noexcept -> |
| Dereference operator. | |
| template<typename U = element_type, typename = std::enable_if_t<!std::is_same<std::remove_cv_t<U>, void>::value>> | |
| ARENE_NODISCARD constexpr auto | operator-> () const noexcept -> pointer |
| Arrow operator. | |
| constexpr auto | operator= (non_null &&) -> non_null &=default |
| Default move assignment. | |
| constexpr auto | operator= (non_null const &) -> non_null &=default |
| Default copy assignment. | |
| template<typename U = held_pointer, constraints< std::enable_if_t< std::is_assignable< held_pointer &, U && >::value > > = nullptr> | |
| constexpr auto | operator= (non_null< U > &&move_from) noexcept(std::is_nothrow_assignable< held_pointer &, U && >::value) -> non_null & |
Move assignment from non_null. | |
| template<typename U = held_pointer, constraints< std::enable_if_t< std::is_assignable< held_pointer &, U const & >::value > > = nullptr> | |
| constexpr auto | operator= (non_null< U > const ©_from) noexcept(std::is_nothrow_assignable< held_pointer &, U const & >::value) -> non_null & |
Copy assignment from non_null. | |
| template<typename U = held_pointer, constraints< std::enable_if_t<!is_non_null_v< U > >, std::enable_if_t< std::is_assignable< held_pointer &, U >::value > > = nullptr> | |
| constexpr auto | operator= (U &&new_ptr) noexcept(std::is_nothrow_assignable< held_pointer &, U >::value) -> non_null & |
| Assignment from a pointer type. | |
| constexpr void | reset (std::nullptr_t) noexcept=delete |
Resetting to a nullptr literal is not supported. | |
| template<typename U = held_pointer, constraints< std::enable_if_t< arene::base::pointer::detail::has_reset< held_pointer &, U > > > = nullptr> | |
| constexpr void | reset (U &&reset_to) noexcept(noexcept(std::declval< held_pointer >().reset(std::declval< U >()))) |
Re-assigns the non_null to a new held pointer. | |
| template<typename U = held_pointer, constraints< std::enable_if_t<!arene::base::pointer::detail::has_reset< held_pointer &, U > >, std::enable_if_t< std::is_assignable< held_pointer &, U >::value > > = nullptr> | |
| constexpr void | reset (U &&reset_to) noexcept(std::is_nothrow_assignable< held_pointer &, U >::value) |
Re-assigns the non_null to a new held pointer. | |
| template<typename U = P, constraints< std::enable_if_t< is_swappable_v< P > > > = nullptr> | |
| constexpr void | swap (non_null &swap_with) noexcept(is_nothrow_swappable_v< P >) |
Swaps this with another non_null . | |
| template<typename U = held_pointer, constraints< std::enable_if_t< std::is_pointer< U >::value > > = nullptr> | |
| ARENE_NODISCARD constexpr auto | get () const noexcept -> held_pointer |
| Gets a pointer to the pointed-to element. | |
| template<typename U = held_pointer, constraints< std::enable_if_t<!std::is_pointer< U >::value > > = nullptr> | |
| ARENE_NODISCARD constexpr auto | get () const noexcept -> |
| Gets a pointer to the pointed-to element. | |
| ARENE_NODISCARD constexpr auto | unwrap () const &noexcept -> held_pointer const & |
Gets the held pointer backing the non_null. | |
| template<typename U = held_pointer, constraints< std::enable_if_t<!std::is_pointer< U >::value > > = nullptr> | |
| ARENE_NODISCARD constexpr auto | unwrap () &&noexcept -> held_pointer && |
Gets the held pointer backing the non_null. | |
| template<typename U = held_pointer, constraints< std::enable_if_t<!std::is_pointer< U >::value > > = nullptr> | |
| ARENE_NODISCARD constexpr | operator bool () const noexcept |
Conversion to bool , equivalent to a != comparison to nullptr. | |
| template<typename U = held_pointer, constraints< std::enable_if_t< std::is_pointer< U >::value > > = nullptr> | |
| ARENE_NODISCARD constexpr | operator bool () const noexcept |
Conversion to bool , equivalent to a != comparison to nullptr. | |
| ARENE_NODISCARD constexpr | operator held_pointer const & () const &noexcept |
| Implicit conversion operator to the underlying pointer. | |
| template<typename U = held_pointer, constraints< std::enable_if_t<!std::is_pointer< U >::value > > = nullptr> | |
| ARENE_NODISCARD constexpr | operator held_pointer && () &&noexcept |
| Implicit conversion operator to the underlying pointer. | |
| template<typename U, constraints< std::enable_if_t<!is_non_null_v< U > >, std::enable_if_t< std::is_constructible< U, held_pointer const & >::value > > = nullptr> | |
| ARENE_NODISCARD constexpr | operator U () const &noexcept(std::is_nothrow_constructible< U, held_pointer const & >::value) |
Explicit conversion operator to U. | |
| template<typename U, constraints< std::enable_if_t<!is_non_null_v< U > >, std::enable_if_t<!std::is_pointer< U >::value >, std::enable_if_t< std::is_constructible< U, held_pointer && >::value > > = nullptr> | |
| ARENE_NODISCARD constexpr | operator U () &&noexcept(std::is_nothrow_constructible< U, held_pointer && >::value) |
Explicit conversion operator to U. | |
| template<typename I> | |
| constexpr auto | operator[] (I)=delete |
| Pointer arithmetic is explicitly deleted. | |
| template<typename I> | |
| constexpr auto | operator[] (I) const =delete |
| Pointer arithmetic is explicitly deleted. | |
| template<typename I> | |
| constexpr auto | operator+ (I const &) const -> non_null=delete |
| Pointer arithmetic is explicitly deleted. | |
| template<typename I> | |
| constexpr auto | operator- (I const &) const -> non_null=delete |
| Pointer arithmetic is explicitly deleted. | |
| constexpr auto | operator++ () -> non_null &=delete |
| Pointer arithmetic is explicitly deleted. | |
| constexpr auto | operator++ (int) -> non_null &=delete |
| Pointer arithmetic is explicitly deleted. | |
| constexpr auto | operator-- () -> non_null &=delete |
| Pointer arithmetic is explicitly deleted. | |
| constexpr auto | operator-- (int) -> non_null &=delete |
| Pointer arithmetic is explicitly deleted. | |
Static Public Member Functions | |
| template<typename Dummy = held_pointer, constraints< std::enable_if_t< std::is_pointer< Dummy >::value > > = nullptr> | |
| static ARENE_NODISCARD constexpr auto | three_way_compare (non_null const &, std::nullptr_t const) noexcept -> strong_ordering |
Three-way comparison of non_null against a null pointer. | |
| template<typename OtherType, constraints< std::enable_if_t< compare_three_way_supported_v< held_pointer const &, OtherType const & > > > = nullptr> | |
| static ARENE_NODISCARD constexpr auto | three_way_compare (non_null const &lhs, non_null< OtherType > const &rhs) noexcept -> strong_ordering |
Three-way comparison between two non_null instances. The result is equivalent to comparing the held pointers. | |
| template<typename OtherType, constraints< std::enable_if_t< compare_three_way_supported_v< held_pointer const &, OtherType const & > >, std::enable_if_t<!is_non_null_v< OtherType > > > = nullptr> | |
| static ARENE_NODISCARD constexpr auto | three_way_compare (non_null const &lhs, OtherType const &rhs) noexcept -> strong_ordering |
Three-way comparison of non_null against another value. The result is equivalent to comparing the held pointer against that other value. | |
| template<typename Dummy = held_pointer, constraints< std::enable_if_t<!std::is_pointer< Dummy >::value > > = nullptr> | |
| static ARENE_NODISCARD constexpr auto | three_way_compare (non_null const &lhs, std::nullptr_t const) noexcept -> strong_ordering |
Three-way comparison of non_null against a null pointer. | |
Public Attributes | |
| using | pointer |
The type of a raw pointer to the element pointed to by the non_null . | |
Friends | |
| template<typename OtherType, constraints< std::enable_if_t< is_equality_comparable_v< held_pointer const &, OtherType const & > > > = nullptr> | |
| ARENE_NODISCARD friend constexpr auto | operator== (non_null const &lhs, non_null< OtherType > const &rhs) noexcept -> bool |
Equality comparison between two non_null instances. The result is equivalent to comparing the held pointers. | |
| ARENE_NODISCARD friend constexpr auto | operator== (non_null const &lhs, std::nullptr_t const rhs) noexcept -> bool |
Equality comparison of non_null against a null pointer. | |
| template<typename NonNullType, typename OtherType, constraints< std::enable_if_t< std::is_same< NonNullType, non_null >::value >, std::enable_if_t<!is_non_null_v< OtherType > >, std::enable_if_t< is_equality_comparable_v< held_pointer const &, OtherType const & > > > = nullptr> | |
| ARENE_NODISCARD friend constexpr auto | operator== (NonNullType const &lhs, OtherType const &rhs) noexcept -> bool |
Equality comparison of non_null against another value. The result is equivalent to comparing the held pointer against that other value. | |
| template<typename U = P, constraints< std::enable_if_t< is_swappable_v< P > > > = nullptr> | |
| constexpr void | swap (non_null &lhs, non_null &rhs) noexcept(noexcept(lhs.swap(rhs))) |
Swaps two non_null . | |
A pointer type which is never nullptr.
| P | The type of the pointer to wrap. |
A wrapper type around a "pointer type" which maintains the invariant that the pointer never be nullptr . It is considered a "malformed program" to attempt to construct a non_null with a pointer which is nullptr , and thus an ARENE_PRECONDITION violation.
models the wrapped pointer type. This means the following properties are true:
get() is equivalent to calling get() on the wrapped pointer if the wrapped pointer is a smart pointer. See non_null<P>::get() for details.reset() is equivalent to calling reset() on the wrapped pointer, if the wrapped pointer is a smart pointer. See non_null<P>::reset() for details.To maintain the invariant that the pointer is never nullptr , it is not possible to obtain a non-const lvalue reference to the wrapped pointer. If P is not a raw pointer, it is possible to obtain an rvalue reference to the wrapped pointer via unwrap()&& or by casting from an rvalue-qualified non_null .
| using arene::base::non_null< P >::element_type = typename std::pointer_traits<held_pointer>::element_type |
The type of the element pointed to.
| using arene::base::non_null< P >::held_pointer = P |
The pointer type being wrapped by the non_null .
|
constexprdelete |
non_null cannot be default constructed
|
explicitconstexprdelete |
non_null cannot be constructed from a literal nullptr .
|
constexprdefault |
Default copy constructor.
|
constexprdefault |
Default move constructor.
|
default |
Default destructor.
|
inlineexplicitconstexprnoexcept |
Construction from a pointer type.
| U | The type of the pointer to construct from. Must be convertible to held_pointer |
| ptr_value | The pointer to construct from. |
ptr_value must not be nullptr , or else ARENE_PRECONDITION violation. get() will return a pointer to the element pointed to by ptr_value .
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Gets a pointer to the pointed-to element.
pointer . nullptr .Behavior is as if non_null
models P . This means that:
P is a raw pointer, then returns the pointer.P is a "smart" pointer, then forwards the return from calling get() on the smart pointer. Examples:
|
inlineconstexprnoexcept |
Gets a pointer to the pointed-to element.
pointer . nullptr .Behavior is as if non_null
models P . This means that:
P is a raw pointer, then returns the pointer.P is a "smart" pointer, then forwards the return from calling get() on the smart pointer. Examples:
|
inlineexplicitconstexprnoexcept |
Conversion to bool , equivalent to a != comparison to nullptr.
non_null can never contain nullptr , so the return is always true .
|
inlineexplicitconstexprnoexcept |
Conversion to bool , equivalent to a != comparison to nullptr.
non_null can never contain nullptr , so the return is always true .
|
inlineconstexprnoexcept |
Implicit conversion operator to the underlying pointer.
held_pointer is a raw pointer or sufficiently trivial type, this will be a by-value return. Otherwise, it will be a reference.
|
inlineconstexprnoexcept |
Implicit conversion operator to the underlying pointer.
held_pointer is a raw pointer or sufficiently trivial type, this will be a by-value return. Otherwise, it will be a reference.
|
inlineexplicitconstexprnoexcept |
Explicit conversion operator to U.
| U | The type to convert the non_null to. held_pointer must be convertible to U . |
static_cast<U>() to the held pointer.
|
inlineexplicitconstexprnoexcept |
Explicit conversion operator to U.
| U | The type to convert the non_null to. held_pointer must be convertible to U . |
static_cast<U>() to the held pointer.
|
inlineconstexprnoexcept |
Boolean negation operator, equivalent to a == comparison to nullptr.
non_null can never contain nullptr , so the return is always false .
|
inlineconstexprnoexcept |
Dereference operator.
nullptr . held_pointer is not void* .
|
constexprdelete |
Pointer arithmetic is explicitly deleted.
|
constexprdelete |
Pointer arithmetic is explicitly deleted.
|
constexprdelete |
Pointer arithmetic is explicitly deleted.
|
constexprdelete |
Pointer arithmetic is explicitly deleted.
|
constexprdelete |
Pointer arithmetic is explicitly deleted.
|
constexprdelete |
Pointer arithmetic is explicitly deleted.
|
inlineconstexprnoexcept |
Arrow operator.
nullptr . held_pointer is not void* .
|
constexprdefault |
Default move assignment.
|
constexprdefault |
Default copy assignment.
|
inlineconstexprnoexcept |
Move assignment from non_null.
| U | Type of the held pointer of the non_null to move. Must be assignable to held_pointer . |
| move_from | The non_null to move |
|
inlineconstexprnoexcept |
Copy assignment from non_null.
| U | Type of the held pointer of the non_null to copy. Must be assignable to held_pointer . |
| copy_from | The non_null to copy |
|
inlineconstexprnoexcept |
Assignment from a pointer type.
| U | The type of the pointer to assign from. Must be assignable to held_pointer |
| new_ptr | The pointer to assign from. |
new_ptr must not be nullptr , or else ARENE_PRECONDITION violation.
|
constexprdelete |
Pointer arithmetic is explicitly deleted.
|
constexprdelete |
Pointer arithmetic is explicitly deleted.
|
constexprdeletenoexcept |
Resetting to a nullptr literal is not supported.
|
inlineconstexprnoexcept |
Re-assigns the non_null to a new held pointer.
The reset is performed using held_pointer::reset() .
| U | The type of pointer to rest with. Must be valid to call held_pointer::rest(U) . |
| reset_to | The pointer to reset the non_null to. |
ptr must not be nullptr , or else ARENE_PRECONDITION violation. ptr . held_pointer::reset(U) is not well formed.
|
inlineconstexprnoexcept |
Re-assigns the non_null to a new held pointer.
The reset is performed by assignment to the held pointer.
| U | The type of pointer to rest with. Must be assignable to held_pointer |
| reset_to | The pointer to reset the non_null to. |
ptr must not be nullptr , or else ARENE_PRECONDITION violation. ptr . held_pointer::reset(U) is well formed.
|
inlineconstexprnoexcept |
Swaps this with another non_null .
| U | Must satisfy arene::base::is_swappable_v |
| swap_with | The non_null to swap with. |
this is equal to the original swap_with, and swap_with is equal to the original this .
|
inlinestaticconstexprnoexcept |
Three-way comparison of non_null against a null pointer.
| Dummy | Dummy template parameter that is the same as held_pointer to enable SFINAE |
strong_ordering::greater
|
inlinestaticconstexprnoexcept |
Three-way comparison between two non_null instances. The result is equivalent to comparing the held pointers.
| OtherType | The type held in the other non_null instance being compared to. held_pointer must be three-way-comparable to OtherType . |
| lhs | The first value being compared |
| rhs | The second value being compared |
lhs to the held pointer of rhs
|
inlinestaticconstexprnoexcept |
Three-way comparison of non_null against another value. The result is equivalent to comparing the held pointer against that other value.
| OtherType | The type to compare the non_null to. It must not be a instantiation of non_null. held_pointer must be comparable to OtherType . |
| lhs | The first value being compared |
| rhs | The second value being compared |
lhs to rhs
|
inlinestaticconstexprnoexcept |
Three-way comparison of non_null against a null pointer.
| Dummy | Dummy template parameter that is the same as held_pointer to enable SFINAE |
| lhs | The non_null value being compared |
strong_ordering::greater unless the non_null instance has been moved from, and wraps a movable smart pointer like std::unique_ptr
|
inlineconstexprnoexcept |
Gets the held pointer backing the non_null.
|
inlineconstexprnoexcept |
Gets the held pointer backing the non_null.
|
friend |
Equality comparison between two non_null instances. The result is equivalent to comparing the held pointers.
| OtherType | The type held in the other non_null instance being compared to. held_pointer must be comparable to OtherType . |
| lhs | The first value being compared |
| rhs | The second value being compared |
lhs to the held pointer of rhs
|
friend |
|
friend |
Equality comparison of non_null against another value. The result is equivalent to comparing the held pointer against that other value.
| NonNullType | Must be non_null This is a constrained template parameter to avoid implicit conversions and ambiguous overload resolution. |
| OtherType | The type to compare the non_null to. It must not be a instantiation of non_null. held_pointer must be comparable to OtherType . |
| lhs | The first value being compared |
| rhs | The second value being compared |
lhs to the other value Swaps two non_null .
| U | Must satisfy arene::base::is_swappable_v |
lhs.swap(rhs) | using arene::base::non_null< P >::pointer |
The type of a raw pointer to the element pointed to by the non_null .