mirror of
https://github.com/sendyne/cppreg.git
synced 2025-05-09 23:24:05 +00:00
For some reason compilers other than GCC PowerPC 4.5.8 were not complaining about the `use_shadow` being (re)defined outside the `Shadow` structure definition. This closes #2.
51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
//! Simple shadow value implementation.
|
|
/**
|
|
* @file ShadowValue.h
|
|
* @author Nicolas Clauvelin (nclauvelin@sendyne.com)
|
|
* @copyright Copyright 2010-2018 Sendyne Corp. All rights reserved.
|
|
*/
|
|
|
|
|
|
#ifndef CPPREG_SHADOWVALUE_H
|
|
#define CPPREG_SHADOWVALUE_H
|
|
|
|
|
|
#include "cppreg_Defines.h"
|
|
|
|
|
|
//! cppreg namespace.
|
|
namespace cppreg {
|
|
|
|
|
|
//! Shadow value generic implementation.
|
|
/**
|
|
* @tparam Register Register type.
|
|
* @tparam UseShadow Boolean flag indicating if shadow value is required.
|
|
*
|
|
* This implementation is for register which do not require shadow value.
|
|
*/
|
|
template <typename Register, bool UseShadow>
|
|
struct Shadow {
|
|
constexpr static const bool use_shadow = false;
|
|
};
|
|
|
|
|
|
//! Shadow value implementation.
|
|
/**
|
|
* @tparam Register Register type.
|
|
*
|
|
* This implementation is for register which do require shadow value.
|
|
*/
|
|
template <typename Register>
|
|
struct Shadow<Register, true> {
|
|
static typename Register::type value;
|
|
constexpr static const bool use_shadow = true;
|
|
};
|
|
template <typename Register>
|
|
typename Register::type Shadow<Register, true>::value = Register::reset;
|
|
|
|
}
|
|
|
|
|
|
#endif // CPPREG_SHADOWVALUE_H
|