Sources Pipelines Documentation

Allocators  
allocation_guard.ipp
1 #pragma once
2 
3 #include "allocation_guard.hpp"
4 
5 
6 namespace boost { namespace memory {
7 
8 template <typename allocator_type>
9 allocation_guard<allocator_type>::allocation_guard(allocator_type& allocator, size_t size)
10  :
11  allocator_(allocator),
12  allocated_block_(allocator.allocate(size))
13 {
14 
15 }
16 
17 template <typename allocator_type>
19 {
20  if (allocated_block_ != null_block)
21  allocator_.deallocate(allocated_block_);
22 }
23 
24 template <typename allocator_type>
26 {
27  return allocated_block_;
28 }
29 
30 } }
31 
~allocation_guard()
Deallocates the block.
allocation_guard(allocator_type &allocator, size_t size)
Allocates a block of given size in RAII style.
Provides a convenient RAII-style mechanism for owning a memory block.
Represents an allocated memory block.