|
libbmb
Modern implementation of STL
|
Unifined interface for allocators. More...
#include <allocator.h>
Public Types | |
| using | allocator_type = Alloc |
Static Public Member Functions | |
| template<typename T , typename... Args> | |
| static void | construct (Alloc &alloc, T *ptr, Args &&... args) |
| Forwards given arguments to allocator's construct method if present. Otherwise uses placement new. | |
| template<typename T > | |
| static void | destroy (Alloc &alloc, T *ptr) |
| Destroys object throgh alloctor if destroy method is present. Otherwise calls ~T() | |
| template<typename T > | |
| static T * | allocate (Alloc &alloc, size_t n) |
| Allocates given number of objects using allocator. | |
| template<typename T > | |
| static void | deallocate (Alloc &alloc, T *ptr, size_t n) |
| Deallocates memory under ptr through allocator. | |
Unifined interface for allocators.
All callers to any allocator should do it throw this class-proxy. It predefines some default methods in case a allocator dosn't do it. Otherwise it calls the allocator's method.
Allocates given number of objects using allocator.
| alloc | Allocator to use for allocation |
| n | Number of objects to allocate |
| Same | as alloc.allocate(...) |
|
inlinestatic |
Forwards given arguments to allocator's construct method if present. Otherwise uses placement new.
| alloc | Allocator to use in construction |
| ptr | Pointer to raw memory where to construct |
| args... | Arguments to pass in constructor |
| Same | as alloc.construct(...) if present. Otherwise same specification as new |
|
inlinestatic |
Deallocates memory under ptr through allocator.
| alloc | Allocator to use in deallocation |
| ptr | Pointer to the previously allocated memory |
| n | Number of objects to deallocate |
| Same | specification as alloc.deallocate() |
Destroys object throgh alloctor if destroy method is present. Otherwise calls ~T()
| alloc | Allocator to use in destruction |
| ptr | Pointer to object to destroy |
| If | allocator has method destroy - throws the same. Otherwise doesn't throw(in assumption object destructor doesn't throw) |