当前位置:网站首页>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 .
边栏推荐
- MVC source code sharing
- [golang] time related
- Simple use of typescript's class interface
- Gof23 - abstract factory pattern
- Message queuing - omnidirectional comparison
- 稀疏数组sparsearray
- Research Report on market supply and demand and strategy of China's microneedle device industry
- Work accumulation - problems encountered in using ThreadLocal in web requests
- A tragedy triggered by "yyyy MM DD" and vigilance before New Year's Day~
- Unsatisfied dependency expressed through field ‘baseMapper‘; nested exceptio
猜你喜欢

Message queue - message transaction management comparison

Dpdk - tcp/udp protocol stack server implementation (II)

Efk upgrade to Clickhouse log storage practice

Library management system

【Spark】Spark SQL 字段血缘如何实现

闭包问题C# Lua

DPDK——TCP/UDP协议栈服务端实现(二)

GoF23—抽象工厂模式

Evolution history of qunar Bi platform construction
![[spark] how to implement spark SQL field blood relationship](/img/8e/96f83844b480916b2662b0cf1fdf65.jpg)
[spark] how to implement spark SQL field blood relationship
随机推荐
Data visualization practice: Data Visualization
Go learning notes 1.3- data types of variables
Reasons why MySQL indexes are not effective
A tragedy triggered by "yyyy MM DD" and vigilance before New Year's Day~
浏览器的四大内核:Trident,Gecko,Webkit,Blink
技术能力的思考和总结
Pychart cannot run designer Exe (this application failed to start because no Qt platform plugin could be I appears)
MYSQL索引不生效的原因
China micronutrient market trend report, technical innovation and market forecast
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%
Self attention and multi head self attention (MSA) in transformer
Efk upgrade to Clickhouse log storage practice
Experience the new features of Milvus 2.0 together
Ppt template crawler case
Transaction and message semantics
Zotero使用之自定义参考文献格式
302. minimum rectangular BFS with all black pixels
Introduction to the use of TS generics in functions, interfaces and classes
[alluxio & Dachang] the original boss direct employment was applied in this way
TCP connection and disconnection, detailed explanation of state transition diagram