当前位置:网站首页>Distribution operation of D
Distribution operation of D
2022-06-26 06:27:00 【fqbqrr】
void foo(){
}
struct A{
auto opDispatch(string op)() {
writeln;// deliberately , Do not import .
}
}
void test(){
A.init.foo();
}
//dmd -c -o- main.d
When opDispatch
When not compiling , happen . Correct behavior , It should not be parsed Writing lines
function .
use void foo(A a){}
Replace void fun(){}
, Should not compile . But compiled .
opDispatch
When the document does not state that it cannot be compiled , What to do .
We should pay attention to ,opDispatch
Instead of ufcs
.
Recently . I've been looking for explicit calls opDispatch
Reason for not working :
A.init.opDispatch!"foo"();
Even if not compiled ( Then print the error message ), If nothing else Valid member
, The application of opDispatch
.
Possible uses are as follows :
struct A
{
T wrapped;
auto opDispatch(string m, Args...)(Args args) {
mixin("return wrapped." ~ m ~ "(args);");
}
}
It's not necessary constraint
To ensure that , But the cost is high ( confused / Misleading error ).opDispatch
whether * matching *
The principal should not be relied upon , And only rely on Signatures and constraints
, Consistent with function template .
If you don't realize opDispatch
, It is impossible to debug . Refuse
Instantiate instead of generate compilation errors , Can lead to error
heavy load , Even the depth template in the depth domain fails . It's hard to track , The final discovery is opDispatch
Target , But because of Suppress errors
, and Skip quietly
.
Should not rely on Realization
And choose opDispatch
. The error should be Hard compilation
error . Yes forward
Templates , It's easy to be in opDispatch
Used in signature __traits(hasMember)
, To decide whether to instantiate . A small cost , And greatly improve Distribution operations
Error report for .
In the past , Well done .
边栏推荐
- Laravel implements groupby to query the number of packets
- Load balancer does not have available server for client: userService问题解决
- 技术能力的思考和总结
- TCP connection and disconnection, detailed explanation of state transition diagram
- MVC source code sharing
- TS泛型在函数、接口、类中使用介绍
- Transformer中的Self-Attention以及Multi-Head Self-Attention(MSA)
- Go learning notes 1.3- data types of variables
- When vs code uses prettier to format JS, there is a space between the name of the function definition and the parentheses, and ESLIt does not allow this space
- Laravel 实现 groupBy 查询分组数量
猜你喜欢
Install pyinstaller
[micro service series] protocol buffer dynamic analysis
GoF23—抽象工厂模式
同步通信和异步通信的区别以及优缺点
Logstash——Logstash将数据推送至Redis
Basic construction of SSM framework
Alarm operation and Maintenance Center | build an efficient and accurate alarm collaborative processing system
Gof23 - builder mode
Message queue - function, performance, operation and maintenance comparison
TCP連接與斷開,狀態遷移圖詳解
随机推荐
Data visualization practice: Experimental Report
如何让主线程等待子线程执行完毕后再执行
Unsatisfied dependency expressed through field ‘baseMapper‘; nested exceptio
Logstash - logstash pushes data to redis
Mongodb -- use mongodb to intercept the string content in the field and perform grouping statistics
js-下载图片
寶塔服務器搭建及數據庫遠程連接
数据可视化实战:数据可视化
Logstash——Logstash将数据推送至Redis
The four cores of the browser: Trident, gecko, WebKit, blink
Architecture design method
去哪儿网BI平台建设演进史
直播预告丨消防安全讲师培训“云课堂”即将开讲!
100 cases of go language
如何设计好的技术方案
ByteDance starts the employee's sudden wealth plan and buys back options with a large amount of money. Some people can earn up to 175%
A new paradigm for large model application: unified feature representation optimization (UFO)
成水最多的容器
MYSQL索引不生效的原因
PyTorch使用多GPU并行训练及其原理和注意事项