26 #ifndef SEASTAR_MODULE
29 #include <seastar/util/concepts.hh>
30 #include <seastar/util/modules.hh>
36 SEASTAR_MODULE_EXPORT_BEGIN
52 SEASTAR_MODULE_EXPORT_END
67 SEASTAR_CONCEPT( requires requires (T ptr) {
71 inline typename std::pointer_traits<std::remove_const_t<T>>::element_type* checked_ptr_do_get(T& ptr) {
79 inline T* checked_ptr_do_get(T* ptr) noexcept {
101 SEASTAR_MODULE_EXPORT
102 template<
typename Ptr,
typename NullDerefAction = default_null_deref_action>
104 SEASTAR_CONCEPT( requires std::is_default_constructible<NullDerefAction>::value && requires (NullDerefAction action) {
128 checked_ptr() noexcept(noexcept(Ptr(
nullptr))) = default;
130 checked_ptr(Ptr&& ptr) noexcept(std::is_nothrow_move_constructible<Ptr>::value) : _ptr(std::move(ptr)) {}
131 checked_ptr(
const Ptr& p) noexcept(std::is_nothrow_copy_constructible<Ptr>::value) : _ptr(p) {}
141 return internal::checked_ptr_do_get(_ptr);
179 explicit operator bool()
const {
return bool(_ptr); }
181 bool operator==(
const checked_ptr& other)
const {
return _ptr == other._ptr; }
182 bool operator!=(
const checked_ptr& other)
const {
return _ptr != other._ptr; }
187 return std::hash<Ptr>()(_ptr);
196 SEASTAR_MODULE_EXPORT
The exception thrown by a default_null_deref_action.
Definition: checked_ptr.hh:39
seastar::checked_ptr class is a wrapper class that may be used with any pointer type (smart like std:...
Definition: checked_ptr.hh:108
element_type * pointer
Type of the pointer to the underlying element.
Definition: checked_ptr.hh:114
Ptr & operator->()
Definition: checked_ptr.hh:153
size_t hash() const
Definition: checked_ptr.hh:186
element_type & operator*()
Definition: checked_ptr.hh:167
const Ptr & operator->() const
Definition: checked_ptr.hh:146
typename std::pointer_traits< Ptr >::element_type element_type
Underlying element type.
Definition: checked_ptr.hh:111
pointer get() const
Definition: checked_ptr.hh:139
const element_type & operator*() const
Definition: checked_ptr.hh:160
Seastar API namespace.
Definition: abort_on_ebadf.hh:26
Default not engaged seastar::checked_ptr dereferencing action (functor).
Definition: checked_ptr.hh:46
void operator()() const
Definition: checked_ptr.hh:48
size_t operator()(const seastar::checked_ptr< T > &p) const
Definition: checked_ptr.hh:203