Files
compute-runtime/shared/test/common/helpers/variable_backup.h
Pawel Cieslak 8a700c5187 Move non-ult shared files to single directory
Add SKIP_SHARED_UNIT_TESTS flag

Related-To: NEO-5201
Signed-off-by: Pawel Cieslak <pawel.cieslak@intel.com>
2021-02-10 21:03:13 +01:00

39 lines
740 B
C++

/*
* Copyright (C) 2017-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;
};