Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
pimpl/main.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the gobelijn software.
3  * Gobelijn is free software: you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the
5  * Free Software Foundation, either version 3 of the License, or any later
6  * version. Gobelijn is distributed in the hope that it will be useful, but
7  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
8  * or FITNESS FOR A PARTICULAR PURPOSE.
9  * See the GNU General Public License for details. You should have received
10  * a copy of the GNU General Public License along with the software. If not,
11  * see <http://www.gnu.org/licenses/>.
12  *
13  * Copyright 2016, Jan Broeckhove.
14  */
19 #include "MemoryPool.h"
20 
21 #include <iostream>
22 
23 using namespace Pimpl;
24 
25 int main()
26 {
27  // Create a memory pool, and use it to round-trip an integer.
28  MemoryPool pool(sizeof(int));
29  auto* ptr = pool.Allocate<int>();
30  *ptr = 10;
31  std::cout << *ptr << std::endl;
32 }
T * Allocate(size_t size=1)
Allocates a region of memory that is 'size * sizeof(T)' of bytes in size.
Definition: MemoryPool.h:50
A memory pool that uses the pointer-to-implementation idiom under the hood.
Definition: MemoryPool.h:30
Pimpl demo with memory pool.
int main()
Definition: pimpl/main.cpp:25