80template <
typename SharedObjectType>
120 [[
deprecated (
"If you are relying on this function please inform the JUCE team as we are planing on removing this in a subsequent release")]]
121 int getReferenceCount()
const noexcept {
return (
int) sharedObject.
use_count(); }
135 : sharedObject (std::move (
other))
137 jassert (sharedObject !=
nullptr);
153 if (
auto locked = ptr.lock())
166 inline static Weak& weak()
A smart-pointer that automatically creates and manages the lifetime of a shared static instance of a ...
SharedResourcePointer(SharedResourcePointer &&) noexcept=default
Move constructor.
SharedObjectType & getObject() const noexcept
Returns a reference to the shared object.
SharedResourcePointer()=default
Creates an instance of the shared object.
SharedResourcePointer(const SharedResourcePointer &)=default
Copy constructor.
SharedObjectType & operator*() const noexcept
Returns a reference to the shared object.
SharedObjectType & get() const noexcept
Returns a reference to the shared object.
static std::optional< SharedResourcePointer > getSharedObjectWithoutCreating()
Returns the SharedResourcePointer if one already exists, or a null optional otherwise.
SharedObjectType * operator->() const noexcept
Returns a pointer to the shared object.
GenericScopedLock< SpinLock > ScopedLockType
Provides the type of scoped lock to use for locking a SpinLock.
#define JUCE_LEAK_DETECTOR(OwnerClass)
This macro lets you embed a leak-detecting object inside a class.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
IPtr< I > shared(I *p)
Assigning shared object to an IPtr.