old-nall/utility.hpp

19 lines
335 B
C++
Raw Normal View History

2016-05-15 10:42:10 +00:00
#pragma once
#include <utility>
namespace nall {
template<typename T> struct base_from_member {
base_from_member(T value) : value(value) {}
T value;
};
2016-07-03 11:35:22 +00:00
template<typename T> inline auto allocate(uint size, const T& value) -> T* {
2016-05-15 10:42:10 +00:00
T* array = new T[size];
2016-07-03 11:35:22 +00:00
for(uint i = 0; i < size; i++) array[i] = value;
2016-05-15 10:42:10 +00:00
return array;
}
}