Skia
2DGraphicsLibrary
|
Shared pointer class to wrap classes that support a ref()/unref() interface. More...
#include <SkRefCnt.h>
Public Types | |
using | element_type = T |
Public Member Functions | |
constexpr | sk_sp (std::nullptr_t) |
sk_sp (const sk_sp< T > &that) | |
Shares the underlying object by calling ref(), so that both the argument and the newly created sk_sp both have a reference to it. | |
template<typename U , typename = skstd::enable_if_t<std::is_convertible<U*, T*>::value>> | |
sk_sp (const sk_sp< U > &that) | |
sk_sp (sk_sp< T > &&that) | |
Move the underlying object from the argument to the newly created sk_sp. More... | |
template<typename U , typename = skstd::enable_if_t<std::is_convertible<U*, T*>::value>> | |
sk_sp (sk_sp< U > &&that) | |
sk_sp (T *obj) | |
Adopt the bare pointer into the newly created sk_sp. More... | |
~sk_sp () | |
Calls unref() on the underlying object pointer. | |
sk_sp< T > & | operator= (std::nullptr_t) |
sk_sp< T > & | operator= (const sk_sp< T > &that) |
Shares the underlying object referenced by the argument by calling ref() on it. More... | |
template<typename U , typename = skstd::enable_if_t<std::is_convertible<U*, T*>::value>> | |
sk_sp< T > & | operator= (const sk_sp< U > &that) |
sk_sp< T > & | operator= (sk_sp< T > &&that) |
Move the underlying object from the argument to the sk_sp. More... | |
template<typename U , typename = skstd::enable_if_t<std::is_convertible<U*, T*>::value>> | |
sk_sp< T > & | operator= (sk_sp< U > &&that) |
T & | operator* () const |
operator unspecified_bool_type () const | |
bool | operator! () const |
T * | get () const |
T * | operator-> () const |
void | reset (T *ptr=nullptr) |
Adopt the new bare pointer, and call unref() on any previously held object (if not null). More... | |
T *SK_WARN_UNUSED_RESULT | release () |
Return the bare pointer, and set the internal object pointer to nullptr. More... | |
void | swap (sk_sp< T > &that) |
Private Types | |
using | unspecified_bool_type = T *sk_sp::* |
Supports safe bool idiom. More... | |
Private Attributes | |
T * | fPtr |
Shared pointer class to wrap classes that support a ref()/unref() interface.
This can be used for classes inheriting from SkRefCnt, but it also works for other classes that match the interface, but have different internal choices: e.g. the hosted class may have its ref/unref be thread-safe, but that is not assumed/imposed by sk_sp.
|
private |
Supports safe bool idiom.
Obsolete with explicit operator bool.
Adopt the bare pointer into the newly created sk_sp.
No call to ref() or unref() will be made.
Shares the underlying object referenced by the argument by calling ref() on it.
If this sk_sp previously had a reference to an object (i.e. not null) it will call unref() on that object.
|
inline |
Return the bare pointer, and set the internal object pointer to nullptr.
The caller must assume ownership of the object, and manage its reference count directly. No call to unref() will be made.
|
inline |
Adopt the new bare pointer, and call unref() on any previously held object (if not null).
No call to ref() will be made.