当前位置:网站首页>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 .
边栏推荐
- Go学习笔记1.3-变量的数据类型篇
- 稀疏数组sparsearray
- typescript的class结合接口(interface)的简单使用
- Connexion et déconnexion TCP, détails du diagramme de migration de l'état
- Several promotion routines of data governance
- Evolution history of qunar Bi platform construction
- Mongodb -- use mongodb to intercept the string content in the field and perform grouping statistics
- PyTorch使用多GPU并行训练及其原理和注意事项
- 寶塔服務器搭建及數據庫遠程連接
- Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
猜你喜欢

GoF23—抽象工厂模式

直播预告丨消防安全讲师培训“云课堂”即将开讲!

Self attention and multi head self attention (MSA) in transformer

Introduction to canal deployment, principle and use

低代码实时数仓构建系统的设计与实践

How to design a good technical scheme

Number of connections server database message: error number 2003can't connect to MySQL server on 'server address' (10061)

MySQL 索引底层原理

数据治理工作的几种推进套路

实时数仓方案如何选型和构建
随机推荐
浏览器的四大内核:Trident,Gecko,Webkit,Blink
Load balancer does not have available server for client: userService问题解决
实时数仓方案如何选型和构建
Connexion et déconnexion TCP, détails du diagramme de migration de l'état
How can an enterprise successfully complete cloud migration?
New generation engineers teach you how to play with alluxio + ml (Part 1)
View analysis
Tencent's 2022 school recruitment of large factories started with salary, and the general contracting of cabbage is close to 40W!
连接数服务器数据库报:错误号码2003Can‘t connect to MySQL server on ‘服务器地址‘(10061)
事务与消息语义
如何让主线程等待子线程执行完毕后再执行
自顶向下的变成方法
MySQL 索引底层原理
Mysql delete in 不走索引的
DPDK——TCP/UDP协议栈服务端实现(一)
Research Report on market supply and demand and strategy of Chinese amyl cinnamaldehyde (ACA) industry
成水最多的容器
Alarm operation and Maintenance Center | build an efficient and accurate alarm collaborative processing system
PyTorch使用多GPU并行训练及其原理和注意事项
MYSQL索引不生效的原因