Go to the documentation of this file.
29 #ifndef JUCE_SCOPEDPOINTER_H_INCLUDED
30 #define JUCE_SCOPEDPOINTER_H_INCLUDED
69 template <
class ObjectType>
81 : object (objectToTakePossessionOf)
92 : object (objectToTransferFrom.object)
94 objectToTransferFrom.object =
nullptr;
113 if (
this != objectToTransferFrom.getAddress())
117 jassert (
object ==
nullptr ||
object != objectToTransferFrom.object);
119 ObjectType*
const oldObject = object;
120 object = objectToTransferFrom.object;
121 objectToTransferFrom.object =
nullptr;
137 if (
object != newObjectToTakePossessionOf)
139 ObjectType*
const oldObject = object;
140 object = newObjectToTakePossessionOf;
147 #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
149 : object (other.object)
151 other.object =
nullptr;
156 object = other.object;
157 other.object =
nullptr;
164 inline operator ObjectType*()
const noexcept {
return object; }
179 ObjectType*
release()
noexcept { ObjectType*
const o = object;
object =
nullptr;
return o; }
189 jassert (
object != other.object ||
this == other.getAddress() ||
object ==
nullptr);
191 std::swap (
object, other.object);
206 #if ! JUCE_MSVC // (MSVC can't deal with multiple copy constructors)
231 template <
class ObjectType>
234 return static_cast<ObjectType*
> (pointer1) == pointer2;
240 template <
class ObjectType>
243 return static_cast<ObjectType*
> (pointer1) != pointer2;
249 template <
typename Type>
253 #endif // JUCE_SCOPEDPOINTER_H_INCLUDED
ObjectType * release() noexcept
Definition: juce_ScopedPointer.h:179
ObjectType * operator->() const noexcept
Definition: juce_ScopedPointer.h:173
~ScopedPointer()
Definition: juce_ScopedPointer.h:100
ScopedPointer & operator=(ScopedPointer &objectToTransferFrom)
Definition: juce_ScopedPointer.h:111
Definition: juce_ScopedPointer.h:70
void deleteAndZero(ScopedPointer< Type > &)
Definition: juce_ScopedPointer.h:250
#define noexcept
Definition: juce_CompilerSupport.h:141
ObjectType * createCopy() const
Definition: juce_ScopedPointer.h:197
ScopedPointer(ScopedPointer &objectToTransferFrom) noexcept
Definition: juce_ScopedPointer.h:91
ScopedPointer() noexcept
Definition: juce_ScopedPointer.h:75
ScopedPointer(ObjectType *const objectToTakePossessionOf) noexcept
Definition: juce_ScopedPointer.h:80
ObjectType * get() const noexcept
Definition: juce_ScopedPointer.h:167
Type * createCopyIfNotNull(const Type *objectToCopy)
Definition: juce_Memory.h:65
bool operator!=(const ScopedPointer< ObjectType > &pointer1, ObjectType *const pointer2) noexcept
Definition: juce_ScopedPointer.h:241
ObjectType & operator*() const noexcept
Definition: juce_ScopedPointer.h:170
static void destroy(ObjectType *object)
Definition: juce_ContainerDeletePolicy.h:46
void swapWith(ScopedPointer< ObjectType > &other) noexcept
Definition: juce_ScopedPointer.h:185
bool operator==(const ScopedPointer< ObjectType > &pointer1, ObjectType *const pointer2) noexcept
Definition: juce_ScopedPointer.h:232