1
0
mirror of https://github.com/sendyne/cppreg.git synced 2025-05-09 23:24:05 +00:00
cppreg/register/ShadowValue.h
Nicolas Clauvelin c1081a114e Code maintenance
* Revise and simplify most enable_if statements in the project.
* Update code style in all files.
* Update copyright year.
* Add a dedicated Memory.h header with the memory device implementation.
* Update documentation.
* CMake cleanup.
2019-04-24 17:00:57 -04:00

46 lines
1009 B
C++

//! Simple shadow value implementation.
/**
* @file ShadowValue.h
* @author Nicolas Clauvelin (nclauvelin@sendyne.com)
* @copyright Copyright 2010-2019 Sendyne Corp. All rights reserved.
*/
#ifndef CPPREG_SHADOWVALUE_H
#define CPPREG_SHADOWVALUE_H
#include "cppreg_Defines.h"
namespace cppreg {
//! Shadow value generic implementation.
/**
* @tparam Register Register type.
* @tparam use_shadow Boolean flag indicating if shadow value is required.
*/
template <typename Register, bool use_shadow>
struct Shadow : std::false_type {};
//! Shadow value specialization.
/**
* @tparam Register Register type.
*
* This implementation is for register which do require shadow value.
*/
template <typename Register>
struct Shadow<Register, true> : std::true_type {
static typename Register::type shadow_value;
};
template <typename Register>
typename Register::type Shadow<Register, true>::shadow_value = Register::reset;
} // namespace cppreg
#endif // CPPREG_SHADOWVALUE_H