File: d_ptr.h

package info (click to toggle)
kio-extras 4%3A25.04.2-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 31,928 kB
  • sloc: cpp: 28,852; ansic: 3,084; perl: 1,048; xml: 116; sh: 92; python: 28; makefile: 9
file content (46 lines) | stat: -rw-r--r-- 1,390 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 *   SPDX-FileCopyrightText: 2012-2016 Ivan Cukic <ivan.cukic@kde.org>
 *
 *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
 */

#ifndef D_PTR_H
#define D_PTR_H

#include <memory>

namespace kamd
{
namespace utils
{

template<typename T>
class d_ptr
{
private:
    std::unique_ptr<T> d;

public:
    d_ptr();

    template<typename... Args>
    d_ptr(Args &&...);

    ~d_ptr();

    T *operator->() const;
};

#define D_PTR                                                                                                                                                  \
    class Private;                                                                                                                                             \
    friend class Private;                                                                                                                                      \
    const ::kamd::utils::d_ptr<Private> d

#define D_PTRC(cls)                                                                                                                                            \
    friend class cls;                                                                                                                                          \
    const ::kamd::utils::d_ptr<cls> d

} // namespace utils
} // namespace kamd

#endif