source: calamares/trunk/fuentes/src/libcalamares/kdsingleapplicationguard/pimpl_ptr.h @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 13 months ago

sync with github

File size: 1.2 KB
Line 
1#ifndef __KDTOOLSCORE__PIMPL_PTR_H__
2#define __KDTOOLSCORE__PIMPL_PTR_H__
3
4#include "kdtoolsglobal.h"
5
6#ifndef DOXYGEN_RUN
7namespace kdtools {
8#endif
9
10    template <typename T>
11    class pimpl_ptr {
12        KDAB_DISABLE_COPY( pimpl_ptr );
13        T * d;
14    public:
15        pimpl_ptr() : d( new T ) {}
16        explicit pimpl_ptr( T * t ) : d( t ) {}
17        ~pimpl_ptr() { delete d; d = 0; }
18
19        T * get() { return d; }
20        const T * get() const { return d; }
21
22        T * operator->() { return get(); }
23        const T * operator->() const { return get(); }
24
25        T & operator*() { return *get(); }
26        const T & operator*() const { return *get(); }
27
28        KDAB_IMPLEMENT_SAFE_BOOL_OPERATOR( get() )
29    };
30
31    // these are not implemented, so's we can catch their use at
32    // link-time. Leaving them undeclared would open up a comparison
33    // via operator unspecified-bool-type().
34    template <typename T, typename S>
35    void operator==( const pimpl_ptr<T> &, const pimpl_ptr<S> & );
36    template <typename T, typename S>
37    void operator!=( const pimpl_ptr<T> &, const pimpl_ptr<S> & );
38
39#ifndef DOXYGEN_RUN
40} // namespace kdtools
41#endif
42
43#endif /* __KDTOOLSCORE__PIMPL_PTR_H__ */
44
Note: See TracBrowser for help on using the repository browser.