Example Program
Allocators
Examples for memory allocation.
File "allocator.cpp"
A tutorial about the use of allocators.
| 1 | |
| 2 | |
| 3 |
We define an arbitrary class.
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 |
We create 100 instances of MyClass on the heap
using a default temporary allocator object Default .
| 10 | |
| 11 | |
| 12 |
Before the storage is deallocated, the MyClass objects have to be destroyed.
| 13 | |
| 14 |
We can use any kind of object as an allocator.
However, dedicated allocators offer more advanced functionality, e.g. clear.
| 15 | |
| 16 | |
| 17 |
clear can be used to deallocate all storage at once.
| 18 | |
| 19 | |
| 20 |
SeqAn - Sequence Analysis Library - www.seqan.de