当前位置:网站首页>d的is表达式
d的is表达式
2022-06-26 12:58:00 【fqbqrr】
考虑普通局部变量:
int foo = 0;
可分析为:
Type_Name Local_Name Operator Initial_Value
考虑is表达式:
is(typeof(func) Params == __parameters)
这样:
is(Type_Name Local_Name Deconstruction_Pattern)
//后2都是可选的.
类型 | 意思 |
|---|---|
is(Type) | 有类型,但省略了本地名称和解构模式.它只关心类型是否存在. |
is(Type:something) | 用:表明可转为该类型的析构模式. |
is(Type==something) | 精确匹配,最易记 |
is(Type Identifier) | 必须存在某种类型,像整 a一样,名字在型后.跳过析构类型 |
is(Type Identifier:something) | 与前:一样,但可可选本地名 |
is(Type Identifier==something) | 同样 |
文档中还有其他,class等,大多很简单,可初化标识符为其他.看起来,is(A B == C)像B与C在比较,但这是在声明变量.== C整个为析构模式,B为变量.类型整 a=10.
is(MyClass Parents == super)
==super,其为基类.因此把==当作匹配析构模式.更有意义.
static if(is(int[10] == T[N], T, size_t N))
只是,扩展了析构模式.==精确比较,T[N]为声明模型.问题是多数时候编译器不会告诉你模式格式不正确,只是不匹配.因而通过静态断言等来测试.
这样用,可选复杂名:
static if(is(int[10] OriginalType == T[N], T, size_t N))
知道如何分解的时候,就容易搞懂了.
边栏推荐
- Solutions to insufficient display permissions of find and Du -sh
- A primary multithreaded server model
- MySQL数据库讲解(五)
- I have a good word to say, and I admire myself
- Solutions to the failure of last child and first child styles of wechat applet
- Go language - pipeline channel
- 创建一个自己的跨域代理服务器
- [proteus simulation] Arduino uno key start / stop + PWM speed control DC motor speed
- Tips for using nexys A7 development board resources
- Detailed introduction to shell script (4)
猜你喜欢

Beifu PLC realizes zero point power-off hold of absolute value encoder -- use of bias

Basic methods for network diagnosis and hardware troubleshooting of Beifu EtherCAT module

Oplg: new generation cloud native observable best practices

网络远程访问的方式使用树莓派

MySQL数据库讲解(三)

防火墙介绍

Es sauvegarde et restauration des données par instantané

8.Ribbon负载均衡服务调用

Analysis of state transition diagram of Beifu NC axis

33. Use rgbd camera for target detection and depth information output
随机推荐
Nexys A7开发板资源使用技巧
8.Ribbon负载均衡服务调用
ES6 module
【系统分析师之路】第十五章 复盘数据库系统(数据库案例分析)
Electron official docs series: Distribution
Create your own cross domain proxy server
Mysql database explanation (III)
I met the problem of concurrent programming in an interview: how to safely interrupt a running thread
What is the use of index aliases in ES
[how to connect the network] Chapter 1: the browser generates messages
去某东面试遇到并发编程问题:如何安全地中断一个正在运行的线程
MySQL数据库讲解(五)
Detailed sorting of HW blue team traceability process
【Proteus仿真】Arduino UNO按键启停 + PWM 调速控制直流电机转速
[proteus simulation] Arduino uno key start / stop + PWM speed control DC motor speed
MediaPipe手势(Hands)
Cloudcompare - Poisson reconstruction
Electron official docs series: Contributing
ES基於Snapshot(快照)的數據備份和還原
PHP非对称加密算法(RSA)加密机制设计