forked from BinomialLLC/crunch
-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathallocator.h
More file actions
36 lines (31 loc) · 789 Bytes
/
allocator.h
File metadata and controls
36 lines (31 loc) · 789 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
#pragma once
#include "crn_mem.h"
namespace crnlib
{
template <class T>
class allocator
{
public:
using value_type = T;
template <class U> allocator(allocator<U> const&) noexcept {}
allocator() noexcept {};
value_type* allocate(std::size_t n)
{
return static_cast<T*>(crnlib_malloc(n * sizeof(T)));
}
void deallocate(value_type* p, std::size_t) noexcept
{
crnlib_free(p);
}
};
template <class T, class U>
bool operator==(allocator<T> const&, allocator<U> const&) noexcept
{
return true;
}
template <class T, class U>
bool operator!=(allocator<T> const& x, allocator<U> const& y) noexcept
{
return !(x == y);
}
}