2014-07-16 01:03:52 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
template <typename T>
|
2023-08-02 17:35:35 +01:00
|
|
|
class DefaultVariable {
|
|
|
|
public:
|
|
|
|
DefaultVariable(const T& value) { defaultValue = value; }
|
|
|
|
DefaultVariable<T>& operator=(const T& value)
|
2018-07-15 13:51:05 +01:00
|
|
|
{
|
|
|
|
currentValue = value;
|
|
|
|
is_default = currentValue == defaultValue;
|
|
|
|
is_explicit = true;
|
|
|
|
return *this;
|
|
|
|
}
|
2023-08-02 17:35:35 +01:00
|
|
|
operator const T&() const { return is_default ? defaultValue : currentValue; }
|
|
|
|
bool isDefault() const { return is_default; }
|
|
|
|
bool isExplicit() const { return is_explicit; }
|
|
|
|
|
|
|
|
private:
|
2018-07-15 13:51:05 +01:00
|
|
|
T currentValue;
|
|
|
|
T defaultValue;
|
|
|
|
bool is_default = true;
|
|
|
|
bool is_explicit = false;
|
2014-07-16 01:03:52 +01:00
|
|
|
};
|