blob: f4725d696f7e632c6a4cdedaffb17b5d8a1a3f63 (
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_VERIFY(!*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_VERIFY(!*this, "stored object must be explicitly released");
}
};
|