-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCountedObjectWrapper.h
38 lines (31 loc) · 1.23 KB
/
CountedObjectWrapper.h
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
/*
This file is part of the Util library.
Copyright (C) 2007-2012 Benjamin Eikel <[email protected]>
Copyright (C) 2007-2012 Claudius Jähn <[email protected]>
Copyright (C) 2007-2012 Ralf Petring <[email protected]>
This library is subject to the terms of the Mozilla Public License, v. 2.0.
You should have received a copy of the MPL along with this library; see the
file LICENSE. If not, you can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef COUNTED_OBJECT_WRAPPER_H
#define COUNTED_OBJECT_WRAPPER_H
#include "ReferenceCounter.h"
#include <utility>
namespace Util {
//! @ingroup reference
template<class _T>
class CountedObjectWrapper : public ReferenceCounter<CountedObjectWrapper<_T>>{
_T obj;
public:
template<typename...args> explicit CountedObjectWrapper(args&&... params) : obj(std::forward<args>(params)...){}
~CountedObjectWrapper() = default;
CountedObjectWrapper & operator=(CountedObjectWrapper&) = delete;
_T & operator*() { return obj; }
const _T & operator*() const { return obj; }
_T * operator->() { return &obj; }
const _T * operator->() const { return &obj; }
_T & get() { return obj; }
const _T & get() const { return obj; }
};
}
#endif // COUNTED_OBJECT_WRAPPER_H