Rumba C++ SDK
StackVector.h
Go to the documentation of this file.
1 /*
2 
3  *
4  ***
5  *****
6  ********************* Mercenaries Engineering SARL
7  ***************** Copyright (C) 2018
8  *************
9  ********* http://www.mercenaries-engineering.com
10  ***********
11  **** ****
12  ** **
13 
14 */
15 #pragma once
16 
17 #include "BufferAllocator.h"
18 
19 namespace maquina
20 {
21 
26 #define STACK_VECTOR(name, T, size) T* __##name##__ptr = (T*)alloca(sizeof(T)*size);\
27  std::vector<T, maquina::BufferAllocator<T>> name(size, maquina::BufferAllocator<T>(__##name##__ptr, size));
28 
33 #define STACK_VECTOR_VALUE(name, T, size, value) T* __##name##__ptr = (T*)alloca(sizeof(T)*size);\
34  std::vector<T, maquina::BufferAllocator<T>> name(size, value, maquina::BufferAllocator<T>(__##name##__ptr, size));
35 
40 #define STACK_VECTOR_RESERVED(name, T, size) T* __##name##__ptr = (T*)alloca(sizeof(T)*size);\
41  std::vector<T, maquina::BufferAllocator<T>> name(maquina::BufferAllocator<T>(__##name##__ptr, size));\
42  name.reserve(size);
43 
48 #define STACK_VECTOR_LIMIT(name, T, size, limit) T* __##name##__ptr = (T*)alloca(sizeof(T)*std::min(size_t(size), size_t(limit)));\
49  std::vector<T, maquina::BufferAllocator<T>> name(size, maquina::BufferAllocator<T>(__##name##__ptr, std::min(size_t(size), size_t(limit))));
50 
55 #define STACK_VECTOR_VALUE_LIMIT(name, T, size, value, limit) T* __##name##__ptr = (T*)alloca(sizeof(T)*std::min(size_t(size), size_t(limit)));\
56  std::vector<T, maquina::BufferAllocator<T>> name(size, value, maquina::BufferAllocator<T>(__##name##__ptr, std::min(size_t(size), size_t(limit))));
57 
62 #define STACK_VECTOR_RESERVED_LIMIT(name, T, size, limit) T* __##name##__ptr = (T*)alloca(sizeof(T)*std::min(size_t(size), size_t(limit)));\
63  std::vector<T, maquina::BufferAllocator<T>> name(maquina::BufferAllocator<T>(__##name##__ptr, std::min(size_t(size), size_t(limit))));\
64  name.reserve(size);
65 
66 }
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20