blob: bd56e5335c7ad655cba1be1d041d62f16331fcc5 (
plain) (
blame)
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
|
#pragma once
#include <util/generic/ptr.h>
template <typename T>
class TNonDestroyingHolder: public THolder<T> {
public:
TNonDestroyingHolder(T* t = nullptr) noexcept
: THolder<T>(t)
{
}
TNonDestroyingHolder(TAutoPtr<T> t) noexcept
: THolder<T>(t)
{
}
~TNonDestroyingHolder() {
Y_ABORT_UNLESS(!*this, "stored object must be explicitly released");
}
};
template <class T>
class TNonDestroyingAutoPtr: public TAutoPtr<T> {
public:
inline TNonDestroyingAutoPtr(T* t = 0) noexcept
: TAutoPtr<T>(t)
{
}
inline TNonDestroyingAutoPtr(const TAutoPtr<T>& t) noexcept
: TAutoPtr<T>(t.Release())
{
}
inline ~TNonDestroyingAutoPtr() {
Y_ABORT_UNLESS(!*this, "stored object must be explicitly released");
}
};
|