2010-08-09 13:28:56 +00:00
|
|
|
#ifndef NALL_UTILITY_HPP
|
|
|
|
#define NALL_UTILITY_HPP
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
namespace nall {
|
2013-05-02 11:25:45 +00:00
|
|
|
|
|
|
|
template<typename T> struct base_from_member {
|
|
|
|
base_from_member(T value) : value(value) {}
|
2015-07-14 09:32:43 +00:00
|
|
|
T value;
|
2013-05-02 11:25:45 +00:00
|
|
|
};
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
template<typename T> inline auto allocate(unsigned size, const T& value) -> T* {
|
2013-05-02 11:25:45 +00:00
|
|
|
T* array = new T[size];
|
|
|
|
for(unsigned i = 0; i < size; i++) array[i] = value;
|
|
|
|
return array;
|
|
|
|
}
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|