-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathallocator_handler.hpp
More file actions
41 lines (33 loc) · 871 Bytes
/
allocator_handler.hpp
File metadata and controls
41 lines (33 loc) · 871 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
36
37
38
39
40
41
#ifndef ALLOCATOR_HANDLER_HPP
#define ALLOCATOR_HANDLER_HPP
#include "handler_memory.hpp"
#include "handler_allocator.hpp"
template <typename Handler>
class allocator_handler
{
public:
using allocator_type = handler_allocator<Handler>;
allocator_handler(handler_memory& memory, Handler handler) :
memory_(memory),
handler_(handler)
{
}
allocator_type get_allocator() const noexcept
{
return handler_allocator<Handler>(memory_);
}
template <typename ...Args>
void operator()(Args&&... args)
{
handler_(std::forward<Args>(args)...);
}
private:
handler_memory& memory_;
Handler handler_;
};
template <typename Handler>
inline allocator_handler<Handler> make_allocation_handler(handler_memory& m, Handler h)
{
return allocator_handler<Handler>(m, h);
}
#endif // ALLOCATOR_HANDLER_HPP