Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_pinned_shared_ptr.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef KIS_PINNED_SHARED_PTR_H
8#define KIS_PINNED_SHARED_PTR_H
9
10#include "kis_shared_ptr.h"
11
18template <typename T>
20{
24public:
26 {
27 }
28
29 inline KisPinnedSharedPtr(T *other)
30 : BaseClass(other)
31 {
32 }
33
34 template <typename X>
36 : BaseClass(other)
37 {
38 }
39
40
41 template <typename X>
43 : BaseClass(other)
44 {
45 }
46
47
48 inline operator RestrictedBool() const
49 {
50 return this->isNull() ? 0 : reinterpret_cast<NotConvertibleToT*>(1);
51 }
52
53 bool operator!() const
54 {
55 return this->isNull();
56 }
57private:
58 explicit operator const T*() const;
59};
60
61#include <kis_debug.h>
62
63template <typename T>
64inline QDebug operator<<(QDebug dbg, const KisPinnedSharedPtr<T> &ptr)
65{
66 dbg.nospace() << ptr.data();
67 return dbg;
68}
69
70#endif // KIS_PINNED_SHARED_PTR_H
71
NotConvertibleToT * RestrictedBool
KisPinnedSharedPtr(const KisSharedPtr< X > &other)
KisPinnedSharedPtr(const KisWeakSharedPtr< X > &other)
KisSharedPtr< T > BaseClass
bool isNull() const
QDebug operator<<(QDebug dbg, const KisPinnedSharedPtr< T > &ptr)