当前位置:网站首页>d编译时计数
d编译时计数
2022-06-30 22:18:00 【fqbqrr】
enum counter(size_t x = [__traits(allMembers, mixin(__MODULE__))].length)=x;
char[] member(ulong x)
{
char[] buf = "void[0] _X0000000000000000;".dup;
enum mapping = "0123456789abcdef";
foreach_reverse(i; buf.length-17 .. buf.length-1)
{
buf[i] = mapping[x & 0xf];
x >>= 4;
}
return buf;
}
mixin template increment()
{
mixin(member(counter!()));
}
pragma(msg, counter!());
mixin increment;
pragma(msg, counter!());
mixin increment;
pragma(msg, counter!());
或者:生成符号:
enum gensym = q{
"_gensym" ~ __traits(identifier, {
})["__lambda".length .. $]};
//通过λ来求计数.
// 同一行,也工作.
pragma(msg, mixin(gensym)); pragma(msg, mixin(gensym));
static this也可以帮你.
边栏推荐
- "Team training competition" Shandong multi university training 3
- Some memory problems summarized
- When unittest automatically tests multiple use cases, the logging module prints repeatedly to solve the problem
- 牛逼|珍藏多年的工具让我实现了带薪摸鱼自由
- 零样本和少样本学习
- Web APIs comprehensive case -tab column switching - dark horse programmer
- 交易所系统开发如何开发?数字货币交易所系统开发成熟技术案例
- 公有云市场迈入深水区,冷静的亚马逊云还坐得住吗?
- Modify the name of the launched applet
- How to develop the exchange system? Mature technology case of digital currency exchange system development
猜你喜欢

电脑设备管理器在哪里可以找到

实现多方数据安全共享,解决普惠金融信息不对称难题

Is Wu Enda's machine learning suitable for entry?

Do machine learning jobs require graduate students?

深入解析 Apache BookKeeper 系列:第四篇—背压

阿婆做的臭豆腐

基于kubernetes平台微服务的部署

Development techniques - import files using easyexcel (simple example)

电脑版微信文件存储在哪个文件夹可以找到

深入解析 Apache BookKeeper 系列:第四篇—背压
随机推荐
Alibaba Kube eventer MySQL sink simple usage record
How to design test cases
AtCoder Beginner Contest 257
How to judge whether the JS object is empty
Qsort function and Simulation Implementation of qsort function
leetcode:104. 二叉树的最大深度
B_ QuRT_ User_ Guide(33)
[introduction to MySQL] the first conversation · first time in the "database" Mainland
Uniapp third party network request
Using Obsidian with Hugo, markdown's local editing software is seamlessly connected with online
十个最为戳心测试/开程序员笑话,念茫茫人海,该如何寻觅?
Redis的缓存穿透、缓存击穿和缓存雪崩
从PG15 XID64再次跳票说起
Where can I find the computer device manager
腾讯3年,功能测试进阶自动化测试,送给在手工测试中迷茫的你
部门新来了个阿里25K出来的,让我见识到了什么是天花板
What is the experience of pairing with AI? Pilot vs alphacode, Codex, gpt-3
win11更新后任务栏空白怎么办? win11更新后任务栏空白卡死的解决方法
Modify the name of the launched applet
Anti leakage family photo in attack and defense drill