forked from QuantStack/git2cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrapper_base.hpp
More file actions
35 lines (28 loc) · 753 Bytes
/
wrapper_base.hpp
File metadata and controls
35 lines (28 loc) · 753 Bytes
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
#pragma once
template <class T>
class wrapper_base
{
public:
using resource_type = T;
wrapper_base(const wrapper_base&) = delete;
wrapper_base& operator=(const wrapper_base&) = delete;
wrapper_base(wrapper_base&& rhs) noexcept
: p_resource(rhs.p_resource)
{
rhs.p_resource = nullptr;
}
wrapper_base& operator=(wrapper_base&& rhs) noexcept
{
std::swap(p_resource, rhs.p_resource);
return *this;
}
operator resource_type*() const noexcept
{
return p_resource;
}
protected:
// Allocation and deletion of p_resource must be handled by inheriting class.
wrapper_base() = default;
~wrapper_base() = default;
resource_type* p_resource = nullptr;
};