51 if (m_ptr !=
nullptr) {
57 if (m_ptr !=
nullptr) {
69 if (m_ptr !=
nullptr) {
80 requires(!std::same_as<T, U> && std::convertible_to<U*, T*>)
84 if (m_ptr !=
nullptr) {
97 if (m_ptr == rhs.m_ptr) {
101 if (m_ptr !=
nullptr) {
102 dec_ref_count(m_ptr);
107 if (m_ptr !=
nullptr) {
108 inc_ref_count(m_ptr);
120 template <
typename U>
121 requires(!std::same_as<T, U> && std::convertible_to<U*, T*>)
124 if (m_ptr == rhs.m_ptr) {
128 if (m_ptr !=
nullptr) {
129 dec_ref_count(m_ptr);
134 if (m_ptr !=
nullptr) {
135 inc_ref_count(m_ptr);
147 : m_ptr{std::exchange(rhs.m_ptr,
nullptr)} {}
154 template <
typename U>
155 requires(!std::same_as<T, U> && std::convertible_to<U*, T*>)
158 : m_ptr{std::exchange(rhs.m_ptr,
nullptr)} {}
168 if (m_ptr == rhs.m_ptr) {
183 template <
typename U>
184 requires(!std::same_as<T, U> && std::convertible_to<U*, T*>)
187 if (m_ptr == rhs.m_ptr) {
201 constexpr T*
get() const noexcept {
return m_ptr; }
208 constexpr T&
operator*() const noexcept {
return *m_ptr; }
222 explicit constexpr operator bool() const noexcept {
return m_ptr !=
nullptr; }
233 return lhs.m_ptr == rhs.m_ptr;
245 return lhs.m_ptr != rhs.m_ptr;
254 std::nullptr_t)
noexcept {
255 return lhs.m_ptr ==
nullptr;
265 return nullptr == rhs.m_ptr;
275 std::nullptr_t)
noexcept {
276 return lhs.m_ptr !=
nullptr;
287 return nullptr != rhs.m_ptr;
302template <
typename T,
typename... Args>
318template <
typename T,
typename Alloc,
typename... Args>
320 auto ptr = std::allocator_traits<Alloc>::allocate(alloc,
sizeof(T));
321 std::allocator_traits<Alloc>::construct(alloc,
ptr,
322 std::forward<Args>(args)...);
A custom intrusive shared pointer implementation without thread synchronization overhead.
Definition intrusive_shared_ptr.hpp:29
constexpr IntrusiveSharedPtr(IntrusiveSharedPtr< U > &&rhs) noexcept
Move constructs from the given intrusive shared pointer.
Definition intrusive_shared_ptr.hpp:156
constexpr IntrusiveSharedPtr< T > & operator=(IntrusiveSharedPtr< T > &&rhs) noexcept
Move assigns from the given intrusive shared pointer.
Definition intrusive_shared_ptr.hpp:166
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 intrusive_shared_ptr.hpp:263
constexpr T * get() const noexcept
Returns the internal pointer.
Definition intrusive_shared_ptr.hpp:201
constexpr IntrusiveSharedPtr(const IntrusiveSharedPtr< T > &rhs) noexcept
Copy constructs from the given intrusive shared pointer.
Definition intrusive_shared_ptr.hpp:67
constexpr T * operator->() const noexcept
Returns the internal pointer.
Definition intrusive_shared_ptr.hpp:215
constexpr ~IntrusiveSharedPtr()
Definition intrusive_shared_ptr.hpp:56
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 intrusive_shared_ptr.hpp:274
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 intrusive_shared_ptr.hpp:253
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 intrusive_shared_ptr.hpp:231
constexpr IntrusiveSharedPtr() noexcept=default
Constructs an empty intrusive shared pointer.
constexpr IntrusiveSharedPtr(T *ptr) noexcept
Constructs an intrusive shared pointer from the given pointer and takes ownership.
Definition intrusive_shared_ptr.hpp:50
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 intrusive_shared_ptr.hpp:285
constexpr IntrusiveSharedPtr(IntrusiveSharedPtr< T > &&rhs) noexcept
Move constructs from the given intrusive shared pointer.
Definition intrusive_shared_ptr.hpp:146
constexpr T & operator*() const noexcept
Returns the object pointed to by the internal pointer.
Definition intrusive_shared_ptr.hpp:208
constexpr IntrusiveSharedPtr(const IntrusiveSharedPtr< U > &rhs) noexcept
Copy constructs from the given intrusive shared pointer.
Definition intrusive_shared_ptr.hpp:81
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 intrusive_shared_ptr.hpp:243
constexpr IntrusiveSharedPtr< T > & operator=(const IntrusiveSharedPtr< T > &rhs) noexcept
Makes a copy of the given intrusive shared pointer.
Definition intrusive_shared_ptr.hpp:95
Definition expression_graph.hpp:11
IntrusiveSharedPtr< T > make_intrusive_shared(Args &&... args)
Constructs an object of type T and wraps it in an intrusive shared pointer using args as the paramete...
Definition intrusive_shared_ptr.hpp:303
IntrusiveSharedPtr< T > allocate_intrusive_shared(Alloc alloc, Args &&... args)
Constructs an object of type T and wraps it in an intrusive shared pointer using alloc as the storage...
Definition intrusive_shared_ptr.hpp:319
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:327