ORIGINAL
Loading...
Searching...
No Matches
deleter.h
Go to the documentation of this file.
1#ifndef DELETER_H
2#define DELETER_H
3
10
11namespace original {
20 template<typename TYPE>
22 public:
27 constexpr deleterBase() noexcept = default;
28
33 virtual ~deleterBase() = 0;
34
40 virtual void operator()(const TYPE* ptr) const noexcept = 0;
41 };
42
49 template<typename TYPE>
50 class deleterBase<TYPE[]> {
51 public:
55 constexpr deleterBase() noexcept = default;
56
61 virtual ~deleterBase() = 0;
62
68 virtual void operator()(const TYPE* ptr) const noexcept = 0;
69 };
70
78 template<typename TYPE>
79 class deleter final : public deleterBase<TYPE>{
80 public:
81 constexpr deleter() noexcept = default;
82 ~deleter() override = default;
83
89 void operator()(const TYPE* ptr) const noexcept override;
90 };
91
99 template<typename TYPE>
100 class deleter<TYPE[]> final : public deleterBase<TYPE[]>{
101 public:
102 constexpr deleter() noexcept = default;
103 ~deleter() override = default;
104
110 void operator()(const TYPE* ptr) const noexcept override;
111 };
112}
113
114template<typename TYPE>
116
117template<typename TYPE>
119
120template<typename TYPE>
121void original::deleter<TYPE>::operator()(const TYPE* ptr) const noexcept {
122 delete ptr;
123}
124
125template<typename TYPE>
126void original::deleter<TYPE[]>::operator()(const TYPE* ptr) const noexcept {
127 delete[] ptr;
128}
129
130#endif //DELETER_H
constexpr deleterBase() noexcept=default
Default constructor.
virtual ~deleterBase()=0
Pure virtual destructor.
constexpr deleterBase() noexcept=default
Default constructor.
void operator()(const TYPE *ptr) const noexcept override
Deletes an array.
Definition deleter.h:126
void operator()(const TYPE *ptr) const noexcept override
Deletes a single object.
Definition deleter.h:121
Main namespace for the project Original.
Definition algorithms.h:21