| 59 | template <std::size_t N, std::size_t alignment> |
| 60 | template <std::size_t ReqAlign> |
| 61 | char* |
| 62 | arena<N, alignment>::allocate(std::size_t n) |
| 63 | { |
| 64 | static_assert(ReqAlign <= alignment, "alignment is too small for this arena"); |
| 65 | assert(pointer_in_buffer(ptr_) && "short_alloc has outlived arena"); |
| 66 | auto const aligned_n = align_up(n); |
| 67 | if (static_cast<decltype(aligned_n)>(buf_ + N - ptr_) >= aligned_n) |
| 68 | { |
| 69 | char* r = ptr_; |
| 70 | ptr_ += aligned_n; |
| 71 | return r; |
| 72 | } |
| 73 | |
| 74 | static_assert(alignment <= alignof(std::max_align_t), "you've chosen an " |
| 75 | "alignment that is larger than alignof(std::max_align_t), and " |
| 76 | "cannot be guaranteed by normal operator new"); |
| 77 | return static_cast<char*>(::operator new(n)); |
| 78 | } |
| 79 | |
| 80 | template <std::size_t N, std::size_t alignment> |
| 81 | void |
nothing calls this directly
no outgoing calls
no test coverage detected