45 if (m_ptr !=
nullptr) {
46 IntrusiveSharedPtrIncRefCount(m_ptr);
51 if (m_ptr !=
nullptr) {
52 IntrusiveSharedPtrDecRefCount(m_ptr);
61 if (m_ptr !=
nullptr) {
62 IntrusiveSharedPtrIncRefCount(m_ptr);
71 if (m_ptr == rhs.m_ptr) {
75 if (m_ptr !=
nullptr) {
76 IntrusiveSharedPtrDecRefCount(m_ptr);
81 if (m_ptr !=
nullptr) {
82 IntrusiveSharedPtrIncRefCount(m_ptr);
92 : m_ptr{std::exchange(rhs.m_ptr,
nullptr)} {}
99 if (m_ptr == rhs.m_ptr) {
111 constexpr T*
Get() const noexcept {
return m_ptr; }
116 constexpr T&
operator*() const noexcept {
return *m_ptr; }
126 explicit constexpr operator bool() const noexcept {
return m_ptr !=
nullptr; }
134 return lhs.m_ptr == rhs.m_ptr;
143 return lhs.m_ptr != rhs.m_ptr;
150 std::nullptr_t)
noexcept {
151 return lhs.m_ptr ==
nullptr;
159 return nullptr == rhs.m_ptr;
167 std::nullptr_t)
noexcept {
168 return lhs.m_ptr !=
nullptr;
177 return nullptr != rhs.m_ptr;
192template <
typename T,
typename... Args>
208template <
typename T,
typename Alloc,
typename... Args>
210 auto ptr = std::allocator_traits<Alloc>::allocate(alloc,
sizeof(T));
211 std::allocator_traits<Alloc>::construct(alloc,
ptr,
212 std::forward<Args>(args)...);
A custom intrusive shared pointer implementation without thread synchronization overhead.
Definition IntrusiveSharedPtr.hpp:28
friend constexpr bool operator==(std::nullptr_t, const IntrusiveSharedPtr< T > &rhs) noexcept
Returns true if the right-hand intrusive shared pointer points to nullptr.
Definition IntrusiveSharedPtr.hpp:157
constexpr IntrusiveSharedPtr< T > & operator=(IntrusiveSharedPtr< T > &&rhs) noexcept
Move assigns from the given intrusive shared pointer.
Definition IntrusiveSharedPtr.hpp:97
constexpr T * Get() const noexcept
Returns the internal pointer.
Definition IntrusiveSharedPtr.hpp:111
friend constexpr bool operator!=(const IntrusiveSharedPtr< T > &lhs, std::nullptr_t) noexcept
Returns true if the left-hand intrusive shared pointer doesn't point to nullptr.
Definition IntrusiveSharedPtr.hpp:166
constexpr IntrusiveSharedPtr< T > & operator=(const IntrusiveSharedPtr< T > &rhs) noexcept
Makes a copy of the given intrusive shared pointer.
Definition IntrusiveSharedPtr.hpp:69
friend constexpr bool operator==(const IntrusiveSharedPtr< T > &lhs, std::nullptr_t) noexcept
Returns true if the left-hand intrusive shared pointer points to nullptr.
Definition IntrusiveSharedPtr.hpp:149
constexpr ~IntrusiveSharedPtr()
Definition IntrusiveSharedPtr.hpp:50
friend constexpr bool operator==(const IntrusiveSharedPtr< T > &lhs, const IntrusiveSharedPtr< T > &rhs) noexcept
Returns true if the given intrusive shared pointers point to the same object.
Definition IntrusiveSharedPtr.hpp:132
constexpr IntrusiveSharedPtr(T *ptr) noexcept
Constructs an intrusive shared pointer from the given pointer and takes ownership.
Definition IntrusiveSharedPtr.hpp:44
constexpr T & operator*() const noexcept
Returns the object pointed to by the internal pointer.
Definition IntrusiveSharedPtr.hpp:116
constexpr IntrusiveSharedPtr() noexcept=default
Constructs an empty intrusive shared pointer.
friend constexpr bool operator!=(std::nullptr_t, const IntrusiveSharedPtr< T > &rhs) noexcept
Returns true if the right-hand intrusive shared pointer doesn't point to nullptr.
Definition IntrusiveSharedPtr.hpp:175
constexpr IntrusiveSharedPtr(const IntrusiveSharedPtr< T > &rhs) noexcept
Copy constructs from the given intrusive shared pointer.
Definition IntrusiveSharedPtr.hpp:59
constexpr T * operator->() const noexcept
Returns the internal pointer.
Definition IntrusiveSharedPtr.hpp:121
constexpr IntrusiveSharedPtr(IntrusiveSharedPtr< T > &&rhs) noexcept
Move constructs from the given intrusive shared pointer.
Definition IntrusiveSharedPtr.hpp:91
friend constexpr bool operator!=(const IntrusiveSharedPtr< T > &lhs, const IntrusiveSharedPtr< T > &rhs) noexcept
Returns true if the given intrusive shared pointers point to different objects.
Definition IntrusiveSharedPtr.hpp:141
Definition Hessian.hpp:18
IntrusiveSharedPtr< T > AllocateIntrusiveShared(Alloc alloc, Args &&... args)
Constructs an object of type T and wraps it in an intrusive shared pointer using alloc as the storage...
Definition IntrusiveSharedPtr.hpp:209
IntrusiveSharedPtr< T > MakeIntrusiveShared(Args &&... args)
Constructs an object of type T and wraps it in an intrusive shared pointer using args as the paramete...
Definition IntrusiveSharedPtr.hpp:193
Implement std::hash so that hash_code can be used in STL containers.
Definition PointerIntPair.h:280
WPI_BASIC_JSON_TPL_DECLARATION void swap(wpi::WPI_BASIC_JSON_TPL &j1, wpi::WPI_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< wpi::WPI_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< wpi::WPI_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition json.h:5258
decltype(nullptr) nullptr_t
Definition base.h:312