当前位置:网站首页>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
也可以帮你.
边栏推荐
- Anfulai embedded weekly report no. 270: June 13, 2022 to June 19, 2022
- 软件确认测试的内容和流程有哪些?确认测试报告需要多少钱?
- [450. delete nodes in binary search tree]
- 【MySQL入门】第一话 · 初入“数据库”大陆
- Doker的容器数据卷
- Notes [introduction to JUC package and future]
- Vite2 is compatible with lower versions of chrome (such as Sogou 80). Some grammars requiring higher versions are processed through polyfills
- Turn: win others' follow with practical actions
- RIDE:获取图片base64
- 基于kubernetes平台微服务的部署
猜你喜欢
Go language learning notes - Gorm usage - database configuration, table addition | web framework gin (VII)
Do machine learning jobs require graduate students?
"More Ford, more China" saw through the clouds, and the orders of Changan Ford's flagship products exceeded 10000
Golang application ━ installation, configuration and use of Hugo blog system
Architecture of IM integrated messaging system sharing 100000 TPS
Windbg调试工具介绍
基于kubernetes平台微服务的部署
Notes [introduction to JUC package and future]
《安富莱嵌入式周报》第271期:2022.06.20--2022.06.26
《安富莱嵌入式周报》第270期:2022.06.13--2022.06.19
随机推荐
机器学习适合女生学吗?
机器学习工作要求研究生吗?
[micro service ~nacos] configuration center of Nacos
leetcode:104. 二叉树的最大深度
Modify the name of the launched applet
RIDE:获取图片base64
A new one from Ali 25K came to the Department, which showed me what the ceiling is
"More Ford, more China" saw through the clouds, and the orders of Changan Ford's flagship products exceeded 10000
Apache server OpenSSL upgrade
多线程经典案例
"Trust machine" empowers development
How to realize the center progress bar in wechat applet
Based on the open source stream batch integrated data synchronization engine Chunjun data restore DDL parsing module actual combat sharing
Alibaba Kube eventer MySQL sink simple usage record
100 important knowledge points that SQL must master: creating and manipulating tables
请指教同花顺软件究竟是什么?另外想问,现在在线开户安全么?
零样本和少样本学习
latex中 & 号什么含义?
Web APIs comprehensive case -tab column switching - dark horse programmer
Femas:云原生多运行时微服务框架