mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-24 15:12:23 +01:00
byuu says: Basically just a project rename, with s/bsnes/higan and the new icon from lowkee added in. It won't compile on Windows because I forgot to update the resource.rc file, and a path transform command isn't working on Windows. It was really just meant as a starting point, so that v091 WIPs can flow starting from .00 with the new name (it overshadows bsnes v091, so publicly speaking this "shouldn't exist" and will probably be deleted from Google Code when v092 is ready.)
33 lines
885 B
C++
Executable File
33 lines
885 B
C++
Executable File
#ifndef NALL_UTILITY_HPP
|
|
#define NALL_UTILITY_HPP
|
|
|
|
#include <type_traits>
|
|
#include <utility>
|
|
|
|
namespace nall {
|
|
template<typename T> struct base_from_member {
|
|
T value;
|
|
base_from_member(T value_) : value(value_) {}
|
|
};
|
|
|
|
template<typename T> class optional {
|
|
public:
|
|
bool valid;
|
|
T value;
|
|
public:
|
|
inline operator bool() const { return valid; }
|
|
inline const T& operator()() const { if(!valid) throw; return value; }
|
|
inline optional<T>& operator=(const optional<T> &source) { valid = source.valid; value = source.value; return *this; }
|
|
inline optional() : valid(false) {}
|
|
inline optional(bool valid, const T &value) : valid(valid), value(value) {}
|
|
};
|
|
|
|
template<typename T> inline T* allocate(unsigned size, const T &value) {
|
|
T *array = new T[size];
|
|
for(unsigned i = 0; i < size; i++) array[i] = value;
|
|
return array;
|
|
}
|
|
}
|
|
|
|
#endif
|