mirror of
https://github.com/PrimeDecomp/prime.git
synced 2025-12-11 03:47:48 +00:00
Add headers, clang-format, decompctx.py & more
This commit is contained in:
29
include/rstl/optional_object.hpp
Normal file
29
include/rstl/optional_object.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef _RSTL_OPTIONAL_OBJECT_HPP
|
||||
#define _RSTL_OPTIONAL_OBJECT_HPP
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "construct.hpp"
|
||||
|
||||
namespace rstl {
|
||||
template < typename T >
|
||||
class optional_object {
|
||||
public:
|
||||
optional_object() : x4_valid(false) {}
|
||||
optional_object(const T& item) : x0_item(item), x4_valid(true) {}
|
||||
~optional_object() { clear(); }
|
||||
|
||||
T& data() { return x0_item; }
|
||||
operator bool() const { return x4_valid; }
|
||||
void clear() {
|
||||
rstl::destroy(&x0_item);
|
||||
x4_valid = false;
|
||||
}
|
||||
|
||||
private:
|
||||
T x0_item;
|
||||
bool x4_valid;
|
||||
};
|
||||
} // namespace rstl
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user