mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 00:24:58 +08:00
Dates corrected in copyright headers to reflect original publication date (2018 for OpenCL, 2020 for Level Zero). Signed-off-by: lgotszal <lukasz.gotszald@intel.com>
39 lines
740 B
C++
39 lines
740 B
C++
/*
|
|
* Copyright (C) 2018-2021 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
template <typename T>
|
|
class VariableBackup {
|
|
public:
|
|
VariableBackup(T *ptr) : pValue(ptr) {
|
|
oldValue = *ptr;
|
|
}
|
|
VariableBackup(T *ptr, T &&newValue) : pValue(ptr) {
|
|
oldValue = *ptr;
|
|
*pValue = newValue;
|
|
}
|
|
VariableBackup(T *ptr, T &newValue) : pValue(ptr) {
|
|
oldValue = *ptr;
|
|
*pValue = newValue;
|
|
}
|
|
~VariableBackup() {
|
|
*pValue = oldValue;
|
|
}
|
|
void operator=(const T &val) {
|
|
*pValue = val;
|
|
}
|
|
template <typename T2>
|
|
bool operator==(const T2 &val) const {
|
|
return *pValue == val;
|
|
}
|
|
|
|
private:
|
|
T oldValue;
|
|
T *pValue;
|
|
};
|