【发布时间】:2016-01-29 00:20:50
【问题描述】:
我有以下enum:
enum enumLoanPaymentPolicy
{
Unspecified = 0,
InterestInArrears = 1 << 1,
InterestInAdvance = 1 << 2,
RoundUpRepayments = 1 << 3,
RoundInterest = 1 << 4,
RoundUpFlows = 1 << 5,
RoundingMask = RoundUpRepayments | RoundInterest | RoundUpFlows,
};
然后在其他地方,给定这个枚举的值 (foo),我想提取与 Round 相关的位集。
我为此使用foo & RoundingMask,但是我应该使用什么type?
理想情况下,我会使用somethingorother(enumLoanPaymentPolicy) bar = foo & RoundingMask,其中somethingorother 有点像decltype。这甚至可能吗?
【问题讨论】:
-
@LogicStuff 很好的发现。我的谷歌搜索没有出现。
标签: c++