summaryrefslogtreecommitdiff
path: root/euler/include/std/allocator.hpp
blob: e76feb96e9e48ee13fe111b1828333dbdea93187 (plain) (blame)
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
#pragma once

#include <std/fwd/allocator.hpp>

#include <euler/heap.hpp>

namespace std {

  template <class T>
  struct allocator {

    using value_type = T;

    constexpr allocator() noexcept {}
    constexpr allocator(const allocator &other) noexcept {}

    template <class U>
    constexpr allocator(const allocator<U> &other) noexcept {}

    constexpr ~allocator() {}

    constexpr T *allocate(size_t n) {
      return (T *)euler::heap::get_block(n * sizeof(T));
    }

    constexpr void deallocate(T *p, size_t n) {
      euler::heap::return_block(p, n * sizeof(T));
    }

  };

}