-
Notifications
You must be signed in to change notification settings - Fork 0
/
pimpl.hpp
32 lines (26 loc) · 803 Bytes
/
pimpl.hpp
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
#ifndef PIMPL_HPP
#define PIMPL_HPP
#include <memory>
#include <type_traits>
namespace stdx {
namespace pimpl {
namespace _details {
template<typename T>
struct deleter
{
void operator()(T *ptr_) { delete ptr_; }
};
} // namespace _details
template<typename T>
using unique_ptr = std::unique_ptr<T, _details::deleter<T>>;
template <class T>
unique_ptr<T> make_unique() {
return unique_ptr<T>(new T());
}
template <class T, class... Ts>
unique_ptr<T> make_unique(Ts&&... args) {
return unique_ptr<T>(new T(std::forward<Ts>(args)...));
}
} // namespace pimpl
} // namespace stdx
#endif // PIMPL_HPP