2016-01-07 17:14:33 +09:00
|
|
|
#pragma once
|
2010-08-09 22:28:56 +09:00
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
namespace nall {
|
2013-05-02 20:25:45 +09:00
|
|
|
|
2019-01-16 09:46:42 +09:00
|
|
|
using std::tuple;
|
|
|
|
|
2013-05-02 20:25:45 +09:00
|
|
|
template<typename T> struct base_from_member {
|
|
|
|
base_from_member(T value) : value(value) {}
|
2015-07-14 18:32:43 +09:00
|
|
|
T value;
|
2013-05-02 20:25:45 +09:00
|
|
|
};
|
|
|
|
|
2016-09-04 22:51:27 +09:00
|
|
|
template<typename To, typename With> struct castable {
|
|
|
|
operator To&() { return (To&)value; }
|
|
|
|
operator const To&() const { return (const To&)value; }
|
|
|
|
operator With&() { return value; }
|
|
|
|
operator const With&() const { return value; }
|
|
|
|
auto& operator=(const With& value) { return this->value = value; }
|
|
|
|
With value;
|
|
|
|
};
|
|
|
|
|
2021-02-08 18:11:00 +09:00
|
|
|
template<typename T> inline auto allocate(u64 size, const T& value) -> T* {
|
2013-05-02 20:25:45 +09:00
|
|
|
T* array = new T[size];
|
2021-02-08 18:11:00 +09:00
|
|
|
for(u64 i = 0; i < size; i++) array[i] = value;
|
2013-05-02 20:25:45 +09:00
|
|
|
return array;
|
|
|
|
}
|
|
|
|
|
2010-08-09 22:28:56 +09:00
|
|
|
}
|