blob: f6049ebd0252b5f33006437983b729afb2c6e877 (
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
|
#pragma once
#include <util/generic/yexception.h>
namespace NOpenSSL {
template <typename TType, auto Create, auto Destroy, class... Args>
class THolder {
public:
inline THolder(Args... args) {
Ptr = Create(args...);
if (!Ptr) {
throw std::bad_alloc();
}
}
THolder(const THolder&) = delete;
THolder& operator=(const THolder&) = delete;
inline ~THolder() noexcept {
Destroy(Ptr);
}
inline operator TType* () noexcept {
return Ptr;
}
private:
TType* Ptr;
};
}
|