44 if (m_ptr !=
nullptr) {
50 if (m_ptr !=
nullptr) {
60 if (m_ptr !=
nullptr) {
69 requires(!std::same_as<T, U> && std::convertible_to<U*, T*>)
73 if (m_ptr !=
nullptr) {
85 if (m_ptr == rhs.m_ptr) {
89 if (m_ptr !=
nullptr) {
95 if (m_ptr !=
nullptr) {
106 template <
typename U>
107 requires(!std::same_as<T, U> && std::convertible_to<U*, T*>)
111 if (m_ptr == rhs.m_ptr) {
115 if (m_ptr !=
nullptr) {
116 dec_ref_count(m_ptr);
121 if (m_ptr !=
nullptr) {
122 inc_ref_count(m_ptr);
132 : m_ptr{std::exchange(rhs.m_ptr,
nullptr)} {}
137 template <
typename U>
138 requires(!std::same_as<T, U> && std::convertible_to<U*, T*>)
141 : m_ptr{std::exchange(rhs.m_ptr,
nullptr)} {}
149 if (m_ptr == rhs.m_ptr) {
162 template <
typename U>
163 requires(!std::same_as<T, U> && std::convertible_to<U*, T*>)
166 if (m_ptr == rhs.m_ptr) {
178 constexpr T*
get() const noexcept {
return m_ptr; }
183 constexpr T&
operator*() const noexcept {
return *m_ptr; }
193 explicit constexpr operator bool() const noexcept {
return m_ptr !=
nullptr; }
202 return lhs.m_ptr == rhs.m_ptr;
212 return lhs.m_ptr != rhs.m_ptr;
219 std::nullptr_t)
noexcept {
220 return lhs.m_ptr ==
nullptr;
228 return nullptr == rhs.m_ptr;
236 std::nullptr_t)
noexcept {
237 return lhs.m_ptr !=
nullptr;
246 return nullptr != rhs.m_ptr;
259template <
typename T,
typename... Args>
273template <
typename T,
typename Alloc,
typename... Args>
275 auto ptr = std::allocator_traits<Alloc>::allocate(alloc,
sizeof(T));
276 std::allocator_traits<Alloc>::construct(alloc,
ptr,
277 std::forward<Args>(args)...);
decltype(nullptr) nullptr_t
Definition base.h:322
A custom intrusive shared pointer implementation without thread synchronization overhead.
Definition intrusive_shared_ptr.hpp:27
constexpr IntrusiveSharedPtr(IntrusiveSharedPtr< U > &&rhs) noexcept
Move constructs from the given intrusive shared pointer.
Definition intrusive_shared_ptr.hpp:140
constexpr IntrusiveSharedPtr< T > & operator=(IntrusiveSharedPtr< T > &&rhs) noexcept
Move assigns from the given intrusive shared pointer.
Definition intrusive_shared_ptr.hpp:147
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:226
constexpr T * get() const noexcept
Returns the internal pointer.
Definition intrusive_shared_ptr.hpp:178
constexpr IntrusiveSharedPtr(const IntrusiveSharedPtr< T > &rhs) noexcept
Copy constructs from the given intrusive shared pointer.
Definition intrusive_shared_ptr.hpp:58
constexpr T * operator->() const noexcept
Returns the internal pointer.
Definition intrusive_shared_ptr.hpp:188
friend class IntrusiveSharedPtr
Definition intrusive_shared_ptr.hpp:30
constexpr ~IntrusiveSharedPtr()
Definition intrusive_shared_ptr.hpp:49
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:235
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:218
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:200
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:43
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:244
constexpr IntrusiveSharedPtr(IntrusiveSharedPtr< T > &&rhs) noexcept
Move constructs from the given intrusive shared pointer.
Definition intrusive_shared_ptr.hpp:131
constexpr T & operator*() const noexcept
Returns the object pointed to by the internal pointer.
Definition intrusive_shared_ptr.hpp:183
constexpr IntrusiveSharedPtr(const IntrusiveSharedPtr< U > &rhs) noexcept
Copy constructs from the given intrusive shared pointer.
Definition intrusive_shared_ptr.hpp:71
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:210
constexpr IntrusiveSharedPtr< T > & operator=(const IntrusiveSharedPtr< T > &rhs) noexcept
Makes a copy of the given intrusive shared pointer.
Definition intrusive_shared_ptr.hpp:83
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:260
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:274
Definition StringMap.hpp:773
void swap(wpi::util::StringMap< T > &lhs, wpi::util::StringMap< T > &rhs)
Definition StringMap.hpp:775