mirror of
https://github.com/PrimeDecomp/prime.git
synced 2025-12-14 22:06:09 +00:00
Continue work on CActor::UpdateAnimation; lots of headers n stuff
Former-commit-id: 85284f7640
This commit is contained in:
37
include/rstl/construction_deferred.hpp
Normal file
37
include/rstl/construction_deferred.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef _RSTL_CONSTRUCTION_DEFERRED_HPP
|
||||
#define _RSTL_CONSTRUCTION_DEFERRED_HPP
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "rstl/construct.hpp"
|
||||
|
||||
namespace rstl {
|
||||
template < typename T >
|
||||
class construction_deferred {
|
||||
public:
|
||||
construction_deferred() : m_valid(false) {}
|
||||
|
||||
template < typename A >
|
||||
void build(const A& arg) {
|
||||
rstl::construct(get_ptr(), arg);
|
||||
makeValid();
|
||||
}
|
||||
void clear(); // TODO
|
||||
bool valid() const { return m_valid; }
|
||||
|
||||
T* get_ptr() { return reinterpret_cast< T* >(x0_data); }
|
||||
T& data() {
|
||||
// TODO ensureIsValid
|
||||
return *get_ptr();
|
||||
}
|
||||
T& operator*() { return data(); }
|
||||
|
||||
private:
|
||||
u8 x0_data[sizeof(T)];
|
||||
bool m_valid __attribute__((aligned(4)));
|
||||
|
||||
void makeValid() { m_valid = true; }
|
||||
};
|
||||
} // namespace rstl
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user