当前位置:网站首页>d枚举生成位
d枚举生成位
2022-08-04 23:06:00 【fqbqrr】
static struct S(E, T)
{
private T flags;
private enum mask(string name) = 1 << __traits(getMember, E, name);
pure nothrow @nogc @safe final {
bool opDispatch(string name)(bool v)
{
v ? (flags |= mask!name) : (flags &= ~mask!name);
return v;
}
bool opDispatch(string name)() const scope
{
return !!(flags & mask!name);
}
}
}
enum F {
square,circle,triangle }
S!(F, ubyte) s;
assert(s.square = true);
assert(!(s.circle = false));
assert(s.triangle = true);
assert(s.square);
assert(!s.circle);
assert(s.triangle);
边栏推荐
- 当panic或者die被执行时,或者发生未定义指令时,如何被回调到
- Service Mesh landing path
- 加解密在线工具和进制转化在线工具
- CS8416国产替代DP8416 数字音频接收器
- [Mock Interview - 10 Years of Work] Are more projects an advantage?
- 文章占位 文章占位
- 一点点读懂thermal(一)
- 被领导拒绝涨薪申请,跳槽后怒涨9.5K,这是我的心路历程
- Both synchronized and ReentrantLock are smooth, because they are reentrant locks, and a thread will not deadlock if it takes the lock multiple times. We need reentrant locks
- The market value of 360 has evaporated by 390 billion in four years. Can government and enterprise security save lives?
猜你喜欢
随机推荐
365天深度学习训练营-学习线路
Based on the results of the facts
质量管理大师爱德华·戴明博士经典的质量管理14条原则
C语言实现扫雷 附带源代码
【3D建模制作技巧分享】ZBrush模型制作流程:地精
【游戏建模模型制作全流程】在ZBrush中雕刻恶魔城男性角色模型
PHP(3)
【字符串函数内功修炼】strncpy + strncat + strncmp(二)
Go 语言快速入门指南:什么是 TSL 安全传输层
Jbpm3.2 开发HelloWorld (简单请假流程)客户端
Web安全开发 | 青训营笔记
线上虚拟展馆展示具有哪些优势
[Cultivation of internal skills of string functions] strncpy + strncat + strncmp (2)
【无标题】
【3D建模制作技巧分享】ZBrush如何设置笔刷快捷键
线性DP(下)
地面高度检测/平面提取与检测(Fast Plane Extraction in Organized Point Clouds Using Agglomerative Hierarchical Clu)
一点点读懂cpufreq(二)
[Cultivation of internal skills of string functions] strcpy + strcat + strcmp (1)
【云原生 · Kubernetes】Kubernetes运维









