aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/libsample/privatedtor.h
blob: 05f18ea531a2c2eff18abe22f2deb3d3c6309d9a (plain)
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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#ifndef PRIVATEDTOR_H
#define PRIVATEDTOR_H

#include "libsamplemacros.h"

class PrivateDtor
{
public:
    LIBMINIMAL_DISABLE_COPY_MOVE(PrivateDtor)

    inline static PrivateDtor *instance()
    {
        static PrivateDtor self;
        self.m_instantiations++;
        return &self;
    }

    inline int instanceCalls()
    {
        return m_instantiations;
    }

protected:
    inline int protectedInstanceCalls() { return m_instantiations; }

private:
    int m_instantiations = 0;

    PrivateDtor() noexcept = default;
    ~PrivateDtor() = default;
};

#endif // PRIVATEDTOR_H