13#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_POINTER_NON_OWNING_PTR_HPP_
14#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_POINTER_NON_OWNING_PTR_HPP_
21#include "arene/base/stdlib_choice/cstddef.hpp"
22#include "arene/base/stdlib_choice/enable_if.hpp"
23#include "arene/base/stdlib_choice/hash.hpp"
24#include "arene/base/stdlib_choice/is_convertible.hpp"
25#include "arene/base/stdlib_choice/is_pointer.hpp"
26#include "arene/base/stdlib_choice/is_reference.hpp"
27#include "arene/base/stdlib_choice/remove_const.hpp"
28#include "arene/base/stdlib_choice/remove_pointer.hpp"
70 "Cannot create an object pointer to a raw pointer. Perhaps you "
71 "meant non_owning_ptr<T> for T* semantics, or "
72 "non_owning_ptr<non_owning_ptr<T>> for T** semantics?"
76 "Cannot create an object pointer to a reference. Perhaps you "
77 "meant non_owning_ptr<T> rather than non_owning_ptr<T&>?"
138 constraints<std::enable_if_t<std::is_convertible<typename non_owning_ptr<U>::pointer,
pointer>::value>> =
nullptr>
182 constexpr void reset(U new_ptr =
nullptr) {
183 ptr_ =
static_cast<pointer>(new_ptr);
216 constexpr explicit operator U() const noexcept {
249 return lhs.get() == rhs.get();
254 return lhs.get() < rhs.get();
265 template <
typename I>
267 template <
typename I>
269 template <
typename I>
271 template <
typename I>
309template <typename T, constraints<std::enable_if_t<std::is_pointer<T>::value>> =
nullptr>
constexpr full_ordering_operators_from_less_than_and_equals() noexcept=default
A non-owning, nullable pointer with nullptr checks on dereference.
Definition non_owning_ptr.hpp:66
constexpr auto operator+(I const &) const -> non_owning_ptr=delete
Pointer arithmetic is explicitly deleted.
ARENE_NODISCARD friend constexpr auto operator<(non_owning_ptr const &lhs, non_owning_ptr const &rhs) noexcept -> bool
6-way comparison is equivalent to comparing raw pointers.
Definition non_owning_ptr.hpp:252
ARENE_NODISCARD friend constexpr auto operator==(non_owning_ptr const &lhs, non_owning_ptr const &rhs) noexcept -> bool
6-way comparison is equivalent to comparing raw pointers.
Definition non_owning_ptr.hpp:247
ARENE_NODISCARD constexpr auto operator->() const noexcept -> pointer
Arrow operator.
Definition non_owning_ptr.hpp:202
constexpr non_owning_ptr(pointer new_ptr) noexcept
Constructor from a pointer to T.
Definition non_owning_ptr.hpp:123
ARENE_NODISCARD constexpr auto operator*() const noexcept -> reference
Dereference operator.
Definition non_owning_ptr.hpp:193
T & reference
The type of a reference to T.
Definition non_owning_ptr.hpp:98
constexpr auto operator[](I)=delete
Pointer arithmetic is explicitly deleted.
constexpr auto operator--() -> non_owning_ptr &=delete
Pointer arithmetic is explicitly deleted.
ARENE_NODISCARD constexpr auto get() const noexcept -> pointer
Accesses the held pointer directly.
Definition non_owning_ptr.hpp:167
constexpr non_owning_ptr(non_owning_ptr< U > new_ptr) noexcept
Constructor from non_owning_ptr convertible to the held type.
Definition non_owning_ptr.hpp:140
constexpr non_owning_ptr(U new_ptr) noexcept
Constructor from a raw pointer convertible to the held type.
Definition non_owning_ptr.hpp:157
T element_type
The type of the element pointed to.
Definition non_owning_ptr.hpp:94
constexpr auto operator++() -> non_owning_ptr &=delete
Pointer arithmetic is explicitly deleted.
T * pointer
The type of a pointer to T.
Definition non_owning_ptr.hpp:89
constexpr auto operator-(I const &) const -> non_owning_ptr=delete
Pointer arithmetic is explicitly deleted.
constexpr void reset(U new_ptr=nullptr)
Resets the held pointer to a new value.
Definition non_owning_ptr.hpp:182
constexpr auto operator[](I) const =delete
Pointer arithmetic is explicitly deleted.
ARENE_NODISCARD constexpr auto operator!() const noexcept -> bool
Boolean negation operator.
Definition non_owning_ptr.hpp:235
constexpr auto operator++(int) -> non_owning_ptr &=delete
Pointer arithmetic is explicitly deleted.
constexpr auto operator--(int) -> non_owning_ptr &=delete
Pointer arithmetic is explicitly deleted.
constexpr non_owning_ptr() noexcept=default
Default, trivial constructor.
static constexpr value_type value
Definition integral_constant.hpp:34
#define ARENE_PRECONDITION(condition)
Check that a precondition holds, and terminate the application if it does not.
Definition contract.hpp:150
Definition accumulate.hpp:37
constexpr bool is_instantiation_of_v
Definition is_instantiation_of.hpp:16
::std::nullptr_t nullptr_t
The type of nullptr.
Definition builtin_types.hpp:22
ARENE_NODISCARD constexpr auto make_non_owning_ptr(T ptr) noexcept
non_owning_ptr factory to allow template deduction.
Definition non_owning_ptr.hpp:310
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
constexpr bool is_non_owning_ptr_v
Trait that deduces if a type is an non_owning_ptr to any type.
Definition non_owning_ptr.hpp:49
Definition accumulate.hpp:36
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41
#define ARENE_NODISCARD
An alias for [[nodiscard]] , or a no-op if the attribute is not supported.
Definition nodiscard.hpp:26
constexpr auto operator()(::arene::base::non_owning_ptr< T > const &ptr) const noexcept -> size_t
Calculate the hash of the pointer.
Definition non_owning_ptr.hpp:329
hash function primary template
Definition hash.hpp:179