Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::shared_ptr< T, SAFE > Class Template Reference

Public Types

using original = std::shared_ptr< T >
 
using element_type = typename original::element_type
 
using weak_type = weak_ptr< T, SAFE >
 

Public Member Functions

 shared_ptr (std::nullptr_t)
 
template<class U , typename std::enable_if< compatible_with_t< U, T >::value, int >::type = 0>
 shared_ptr (U *ptr)
 
template<typename DELETER >
 shared_ptr (T *ptr, DELETER deleter)
 
template<class U >
 shared_ptr (const shared_ptr< U > &ref, T *ptr) noexcept
 
template<class U , typename std::enable_if< compatible_with_t< U, T >::value, int >::type = 0>
 shared_ptr (const shared_ptr< U > &ref) noexcept
 
 shared_ptr (const shared_ptr &other)
 
template<class U , typename std::enable_if< compatible_with_t< U, T >::value, int >::type = 0>
 shared_ptr (shared_ptr< U > &&ref) noexcept
 
 shared_ptr (shared_ptr< T, SAFE > &&other) noexcept
 
 shared_ptr (std::shared_ptr< T > other)
 
template<class U >
 shared_ptr (weak_ptr< U > other)
 
template<class U , class DELETER , bool SAFE_P, typename std::enable_if< compatible_with_t< U, T >::value &&std::is_convertible< typename unique_ptr< U, DELETER >::pointer, T * >::value, int >::type = 0>
 shared_ptr (unique_ptr< U, DELETER, SAFE_P > &&other)
 
shared_ptr< T, SAFE > & operator= (const shared_ptr< T, SAFE > &other) noexcept
 
template<class U , typename std::enable_if< compatible_with_t< U, T >::value, int >::type = 0>
shared_ptr< T > & operator= (const shared_ptr< U > &other)
 
shared_ptr< T, SAFE > & operator= (shared_ptr &&other) noexcept
 
template<class U , typename std::enable_if< compatible_with_t< U, T >::value, int >::type = 0>
shared_ptr< T, SAFE > & operator= (shared_ptr< U > &&other)
 
template<class U , class DELETER , bool SAFE_P, typename std::enable_if< compatible_with_t< U, T >::value &&std::is_convertible< typename unique_ptr< U, DELETER >::pointer, T * >::value, int >::type = 0>
shared_ptr< T, SAFE > & operator= (unique_ptr< U, DELETER, SAFE_P > &&ref)
 
void reset ()
 
template<typename U >
void reset (U *ptr)
 
template<typename U , typename DELETER >
void reset (U *ptr, DELETER deleter)
 
void swap (shared_ptr &r) noexcept
 
T * get () const
 
long use_count () const
 
 operator bool () const noexcept
 
std::add_lvalue_reference< T >::type operator* () const
 
T * operator-> () const
 
template<typename U >
bool operator== (const shared_ptr< U > &other) const noexcept
 
template<typename U >
bool operator!= (const shared_ptr< U > &other) const noexcept
 
bool operator== (std::nullptr_t) const noexcept
 
bool operator!= (std::nullptr_t) const noexcept
 
template<typename U >
bool operator< (const shared_ptr< U > &other) const noexcept
 
template<typename U >
bool operator<= (const shared_ptr< U > &other) const noexcept
 
template<typename U >
bool operator> (const shared_ptr< U > &other) const noexcept
 
template<typename U >
bool operator>= (const shared_ptr< U > &other) const noexcept
 
shared_ptr< T, SAFEatomic_load () const
 
shared_ptr< T, SAFEatomic_load (std::memory_order order) const
 
void atomic_store (const shared_ptr< T, SAFE > &new_ptr)
 

Private Member Functions

template<class U , class V , typename std::enable_if< std::is_convertible< V *, const enable_shared_from_this< U > * >::value, int >::type = 0>
void __enable_weak_this (const enable_shared_from_this< U > *object, V *ptr) noexcept
 
void __enable_weak_this (...) noexcept
 

Static Private Member Functions

static void AssertNotNull (const bool null)
 

Private Attributes

original internal
 

Friends

template<class U , bool SAFE_P>
class weak_ptr
 
template<typename U , typename S >
shared_ptr< S > shared_ptr_cast (shared_ptr< U > src)
 

Constructor & Destructor Documentation

◆ shared_ptr() [1/12]

template<typename T , bool SAFE = true>
duckdb::shared_ptr< T, SAFE >::shared_ptr ( )
inline
1535 : internal() {
1536 }

◆ shared_ptr() [2/12]

template<typename T , bool SAFE = true>
duckdb::shared_ptr< T, SAFE >::shared_ptr ( std::nullptr_t  )
inline
1537 : internal(nullptr) { // NOLINT: not marked as explicit
1538 }

◆ shared_ptr() [3/12]

template<typename T , bool SAFE = true>
template<class U , typename std::enable_if< compatible_with_t< U, T >::value, int >::type = 0>
duckdb::shared_ptr< T, SAFE >::shared_ptr ( U *  ptr)
inlineexplicit
1542 : internal(ptr) {
1543 __enable_weak_this(internal.get(), internal.get());
1544 }

◆ shared_ptr() [4/12]

template<typename T , bool SAFE = true>
template<typename DELETER >
duckdb::shared_ptr< T, SAFE >::shared_ptr ( T *  ptr,
DELETER  deleter 
)
inline
1547 : internal(ptr, deleter) {
1548 __enable_weak_this(internal.get(), internal.get());
1549 }

◆ shared_ptr() [5/12]

template<typename T , bool SAFE = true>
template<class U >
duckdb::shared_ptr< T, SAFE >::shared_ptr ( const shared_ptr< U > &  ref,
T *  ptr 
)
inlinenoexcept
1553 : internal(ref.internal, ptr) {
1554 }

◆ shared_ptr() [6/12]

template<typename T , bool SAFE = true>
template<class U , typename std::enable_if< compatible_with_t< U, T >::value, int >::type = 0>
duckdb::shared_ptr< T, SAFE >::shared_ptr ( const shared_ptr< U > &  ref)
inlinenoexcept
1563 : internal(ref.internal) { // NOLINT: not marked as explicit
1564 }

◆ shared_ptr() [7/12]

template<typename T , bool SAFE = true>
duckdb::shared_ptr< T, SAFE >::shared_ptr ( const shared_ptr< T, SAFE > &  other)
inline
1565 : internal(other.internal) { // NOLINT: not marked as explicit
1566 }

◆ shared_ptr() [8/12]

template<typename T , bool SAFE = true>
template<class U , typename std::enable_if< compatible_with_t< U, T >::value, int >::type = 0>
duckdb::shared_ptr< T, SAFE >::shared_ptr ( shared_ptr< U > &&  ref)
inlinenoexcept
1573 : internal(std::move(ref.internal)) {
1574 }

◆ shared_ptr() [9/12]

template<typename T , bool SAFE = true>
duckdb::shared_ptr< T, SAFE >::shared_ptr ( shared_ptr< T, SAFE > &&  other)
inlinenoexcept
1580 : internal(std::move(other.internal)) {
1581 }

◆ shared_ptr() [10/12]

template<typename T , bool SAFE = true>
duckdb::shared_ptr< T, SAFE >::shared_ptr ( std::shared_ptr< T >  other)
inlineexplicit
1584 : internal(other) {
1585 // FIXME: should we __enable_weak_this here?
1586 // *our* enable_shared_from_this hasn't initialized yet, so I think so?
1587 __enable_weak_this(internal.get(), internal.get());
1588 }

◆ shared_ptr() [11/12]

template<typename T , bool SAFE = true>
template<class U >
duckdb::shared_ptr< T, SAFE >::shared_ptr ( weak_ptr< U >  other)
inlineexplicit
1592 : internal(other.internal) {
1593 }

◆ shared_ptr() [12/12]

template<typename T , bool SAFE = true>
template<class U , class DELETER , bool SAFE_P, typename std::enable_if< compatible_with_t< U, T >::value &&std::is_convertible< typename unique_ptr< U, DELETER >::pointer, T * >::value, int >::type = 0>
duckdb::shared_ptr< T, SAFE >::shared_ptr ( unique_ptr< U, DELETER, SAFE_P > &&  other)
inline
1604 : internal(std::move(other)) {
1605 __enable_weak_this(internal.get(), internal.get());
1606 }

Member Function Documentation

◆ AssertNotNull()

template<typename T , bool SAFE = true>
static void duckdb::shared_ptr< T, SAFE >::AssertNotNull ( const bool  null)
inlinestaticprivate
1510 {
1511#if defined(DUCKDB_DEBUG_NO_SAFETY) || defined(DUCKDB_CLANG_TIDY)
1512 return;
1513#else
1514 if (DUCKDB_UNLIKELY(null)) {
1515 throw duckdb::InternalException("Attempted to dereference shared_ptr that is NULL!");
1516 }
1517#endif
1518 }
Definition duckdb.hpp:809

◆ operator=() [1/5]

template<typename T , bool SAFE = true>
shared_ptr< T, SAFE > & duckdb::shared_ptr< T, SAFE >::operator= ( const shared_ptr< T, SAFE > &  other)
inlinenoexcept
1612 {
1613 if (this == &other) {
1614 return *this;
1615 }
1616 // Create a new shared_ptr using the copy constructor, then swap out the ownership to *this
1617 shared_ptr(other).swap(*this);
1618 return *this;
1619 }

◆ operator=() [2/5]

template<typename T , bool SAFE = true>
template<class U , typename std::enable_if< compatible_with_t< U, T >::value, int >::type = 0>
shared_ptr< T > & duckdb::shared_ptr< T, SAFE >::operator= ( const shared_ptr< U > &  other)
inline
1621 {
1622 shared_ptr(other).swap(*this);
1623 return *this;
1624 }

◆ operator=() [3/5]

template<typename T , bool SAFE = true>
shared_ptr< T, SAFE > & duckdb::shared_ptr< T, SAFE >::operator= ( shared_ptr< T, SAFE > &&  other)
inlinenoexcept
1627 {
1628 // Create a new shared_ptr using the move constructor, then swap out the ownership to *this
1629 shared_ptr(std::move(other)).swap(*this);
1630 return *this;
1631 }

◆ operator=() [4/5]

template<typename T , bool SAFE = true>
template<class U , typename std::enable_if< compatible_with_t< U, T >::value, int >::type = 0>
shared_ptr< T, SAFE > & duckdb::shared_ptr< T, SAFE >::operator= ( shared_ptr< U > &&  other)
inline
1633 {
1634 shared_ptr(std::move(other)).swap(*this);
1635 return *this;
1636 }

◆ operator=() [5/5]

template<typename T , bool SAFE = true>
template<class U , class DELETER , bool SAFE_P, typename std::enable_if< compatible_with_t< U, T >::value &&std::is_convertible< typename unique_ptr< U, DELETER >::pointer, T * >::value, int >::type = 0>
shared_ptr< T, SAFE > & duckdb::shared_ptr< T, SAFE >::operator= ( unique_ptr< U, DELETER, SAFE_P > &&  ref)
inline
1643 {
1644 shared_ptr(std::move(ref)).swap(*this);
1645 return *this;
1646 }

◆ reset() [1/3]

template<typename T , bool SAFE = true>
void duckdb::shared_ptr< T, SAFE >::reset ( )
inline
1652 { // NOLINT: invalid case style
1653 internal.reset();
1654 }

◆ reset() [2/3]

template<typename T , bool SAFE = true>
template<typename U >
void duckdb::shared_ptr< T, SAFE >::reset ( U *  ptr)
inline
1660 { // NOLINT: invalid case style
1661 internal.reset(ptr);
1662 }

◆ reset() [3/3]

template<typename T , bool SAFE = true>
template<typename U , typename DELETER >
void duckdb::shared_ptr< T, SAFE >::reset ( U *  ptr,
DELETER  deleter 
)
inline
1668 { // NOLINT: invalid case style
1669 internal.reset(ptr, deleter);
1670 }

◆ swap()

template<typename T , bool SAFE = true>
void duckdb::shared_ptr< T, SAFE >::swap ( shared_ptr< T, SAFE > &  r)
inlinenoexcept
1672 { // NOLINT: invalid case style
1673 internal.swap(r.internal);
1674 }

◆ get()

template<typename T , bool SAFE = true>
T * duckdb::shared_ptr< T, SAFE >::get ( ) const
inline
1676 { // NOLINT: invalid case style
1677 return internal.get();
1678 }

◆ use_count()

template<typename T , bool SAFE = true>
long duckdb::shared_ptr< T, SAFE >::use_count ( ) const
inline
1680 { // NOLINT: invalid case style
1681 return internal.use_count();
1682 }

◆ operator bool()

template<typename T , bool SAFE = true>
duckdb::shared_ptr< T, SAFE >::operator bool ( ) const
inlineexplicitnoexcept
1684 {
1685 return internal.operator bool();
1686 }

◆ operator*()

template<typename T , bool SAFE = true>
std::add_lvalue_reference< T >::type duckdb::shared_ptr< T, SAFE >::operator* ( ) const
inline
1688 {
1689 if (MemorySafety<SAFE>::ENABLED) {
1690 const auto ptr = internal.get();
1691 AssertNotNull(!ptr);
1692 return *ptr;
1693 } else {
1694 return *internal;
1695 }
1696 }

◆ operator->()

template<typename T , bool SAFE = true>
T * duckdb::shared_ptr< T, SAFE >::operator-> ( ) const
inline
1698 {
1699 if (MemorySafety<SAFE>::ENABLED) {
1700 const auto ptr = internal.get();
1701 AssertNotNull(!ptr);
1702 return ptr;
1703 } else {
1704 return internal.operator->();
1705 }
1706 }

◆ operator==() [1/2]

template<typename T , bool SAFE = true>
template<typename U >
bool duckdb::shared_ptr< T, SAFE >::operator== ( const shared_ptr< U > &  other) const
inlinenoexcept
1710 {
1711 return internal == other.internal;
1712 }

◆ operator!=() [1/2]

template<typename T , bool SAFE = true>
template<typename U >
bool duckdb::shared_ptr< T, SAFE >::operator!= ( const shared_ptr< U > &  other) const
inlinenoexcept
1714 {
1715 return internal != other.internal;
1716 }

◆ operator==() [2/2]

template<typename T , bool SAFE = true>
bool duckdb::shared_ptr< T, SAFE >::operator== ( std::nullptr_t  ) const
inlinenoexcept
1718 {
1719 return internal == nullptr;
1720 }

◆ operator!=() [2/2]

template<typename T , bool SAFE = true>
bool duckdb::shared_ptr< T, SAFE >::operator!= ( std::nullptr_t  ) const
inlinenoexcept
1721 {
1722 return internal != nullptr;
1723 }

◆ operator<()

template<typename T , bool SAFE = true>
template<typename U >
bool duckdb::shared_ptr< T, SAFE >::operator< ( const shared_ptr< U > &  other) const
inlinenoexcept
1726 {
1727 return internal < other.internal;
1728 }

◆ operator<=()

template<typename T , bool SAFE = true>
template<typename U >
bool duckdb::shared_ptr< T, SAFE >::operator<= ( const shared_ptr< U > &  other) const
inlinenoexcept
1730 {
1731 return internal <= other.internal;
1732 }

◆ operator>()

template<typename T , bool SAFE = true>
template<typename U >
bool duckdb::shared_ptr< T, SAFE >::operator> ( const shared_ptr< U > &  other) const
inlinenoexcept
1734 {
1735 return internal > other.internal;
1736 }

◆ operator>=()

template<typename T , bool SAFE = true>
template<typename U >
bool duckdb::shared_ptr< T, SAFE >::operator>= ( const shared_ptr< U > &  other) const
inlinenoexcept
1738 {
1739 return internal >= other.internal;
1740 }

◆ atomic_load() [1/2]

template<typename T , bool SAFE = true>
shared_ptr< T, SAFE > duckdb::shared_ptr< T, SAFE >::atomic_load ( ) const
inline
1742 {
1743 return shared_ptr<T, SAFE>(std::atomic_load(&internal));
1744 }

◆ atomic_load() [2/2]

template<typename T , bool SAFE = true>
shared_ptr< T, SAFE > duckdb::shared_ptr< T, SAFE >::atomic_load ( std::memory_order  order) const
inline
1746 {
1747 return shared_ptr<T, SAFE>(std::atomic_load_explicit(&internal, order));
1748 }

◆ atomic_store()

template<typename T , bool SAFE = true>
void duckdb::shared_ptr< T, SAFE >::atomic_store ( const shared_ptr< T, SAFE > &  new_ptr)
inline
1750 {
1751 std::atomic_store(&internal, new_ptr.internal);
1752 }

◆ __enable_weak_this() [1/2]

template<typename T , bool SAFE = true>
template<class U , class V , typename std::enable_if< std::is_convertible< V *, const enable_shared_from_this< U > * >::value, int >::type = 0>
void duckdb::shared_ptr< T, SAFE >::__enable_weak_this ( const enable_shared_from_this< U > *  object,
V ptr 
)
inlineprivatenoexcept
1760 {
1761 typedef typename std::remove_cv<U>::type non_const_u_t;
1762 if (object && object->__weak_this_.expired()) {
1763 // __weak_this__ is the mutable variable returned by 'shared_from_this'
1764 // it is initialized here
1765 auto non_const = const_cast<non_const_u_t *>(static_cast<const U *>(ptr)); // NOLINT: const cast
1766 object->__weak_this_ = shared_ptr<non_const_u_t>(*this, non_const);
1767 }
1768 }

◆ __enable_weak_this() [2/2]

template<typename T , bool SAFE = true>
void duckdb::shared_ptr< T, SAFE >::__enable_weak_this (   ...)
inlineprivatenoexcept
1770 { // NOLINT: invalid case style
1771 }

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