mirror of
https://github.com/PrimeDecomp/prime.git
synced 2025-12-12 18:46:08 +00:00
More main progress; tons of headers & stuff
Former-commit-id: a6e365791b
This commit is contained in:
@@ -13,16 +13,33 @@ public:
|
||||
optional_object(const T& item) : x0_item(item), x4_valid(true) {}
|
||||
~optional_object() { clear(); }
|
||||
|
||||
optional_object& operator=(const T& item) {
|
||||
assign(item);
|
||||
return *this;
|
||||
}
|
||||
|
||||
T& data() { return x0_item; }
|
||||
T* get_ptr() { return &x0_item; }
|
||||
operator bool() const { return x4_valid; }
|
||||
void clear() {
|
||||
rstl::destroy(&x0_item);
|
||||
x4_valid = false;
|
||||
}
|
||||
|
||||
T& operator*() { return data(); }
|
||||
|
||||
private:
|
||||
T x0_item;
|
||||
bool x4_valid;
|
||||
|
||||
void assign(const T& item) {
|
||||
if (!x4_valid) {
|
||||
rstl::construct(get_ptr(), item);
|
||||
x4_valid = true;
|
||||
} else {
|
||||
data() = item;
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace rstl
|
||||
|
||||
|
||||
Reference in New Issue
Block a user