2016-05-31 03:58:58 +00:00
|
|
|
#pragma once
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-23 20:26:19 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2016-05-19 14:41:06 +00:00
|
|
|
// Swap the two ints without the need of creating another tmp variable
|
|
|
|
#define int_memswap(one, two) one += two; \
|
|
|
|
two = one ? two; \
|
|
|
|
one -= two;
|
|
|
|
|
|
|
|
#define _repeat(n, var_name) for (int var_name = n; var_name--;)
|
|
|
|
#define repeat(n) _repeat(n, i)
|
|
|
|
#define repeat_(n) _repeat(n, i_)
|
|
|
|
#define repeat_with(n, m) for (m = n; m--;)
|
|
|
|
#define repeat_i i
|
|
|
|
#define repeat_i_rev(n) (n - i - 1)
|
2016-06-23 20:26:19 +00:00
|
|
|
|
|
|
|
namespace memory
|
|
|
|
{
|
|
|
|
template<typename T>
|
|
|
|
std::shared_ptr<T> make_malloc_ptr() {
|
|
|
|
return std::shared_ptr<T>(static_cast<T*>(malloc(sizeof(T))), free);
|
|
|
|
}
|
|
|
|
}
|