mirror of
https://github.com/copyrighttxt/watrbx-game-engine.git
synced 2026-09-05 05:07:48 +00:00
fahhh
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
namespace RBX
|
||||
{
|
||||
// TODO: This probably exists in some other library somewhere...
|
||||
template <typename V>
|
||||
class ScopedAssign
|
||||
{
|
||||
V* value;
|
||||
V oldValue;
|
||||
public:
|
||||
ScopedAssign() : value(NULL) {}
|
||||
ScopedAssign(V& value, const V& newValue)
|
||||
:value(&value)
|
||||
,oldValue(value)
|
||||
{
|
||||
*(this->value) = newValue;
|
||||
}
|
||||
~ScopedAssign()
|
||||
{
|
||||
if (value)
|
||||
*value = oldValue;
|
||||
}
|
||||
|
||||
void assign (V& value, const V& newValue)
|
||||
{
|
||||
this->value = &value;
|
||||
oldValue = value;
|
||||
*(this->value) = newValue;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user