当前位置:网站首页>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))
知道如何分解的时候,就容易搞懂了.
边栏推荐
- 使用 Performance 看看浏览器在做什么
- Electron official docs series: Examples
- sed编辑器
- What is the use of index aliases in ES
- Basic methods for network diagnosis and hardware troubleshooting of Beifu EtherCAT module
- 【MySQL从入门到精通】【高级篇】(二)MySQL目录结构与表在文件系统中的表示
- [how to connect the network] Chapter 2 (middle): sending a network packet
- Common faults of MySQL database - forgetting database password
- 古瑞瓦特沖刺港交所上市:創下“多個第一”,獲IDG資本9億元投資
- Wechat applet magic bug - choose to replace the token instead of clearing the token, wx Getstoragesync will take the old token value instead of the new token value
猜你喜欢

Here document interaction free and expect automatic interaction

Stack, LIFO

使用 Performance 看看浏览器在做什么

Here Document免交互及Expect自动化交互

Mediapipe gestures (hands)

创建一个自己的跨域代理服务器

输入文本自动生成图像,太好玩了!

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

MySQL讲解(二)

Oplg: new generation cloud native observable best practices
随机推荐
Jenkins build prompt error: eacces: permission denied
mysql讲解(一)
Thinking caused by the error < note: candidate expectations 1 argument, 0 provided >
Chapter 10 setting up structured logging (2)
HW蓝队溯源流程详细整理
ES中索引别名(alias)的到底有什么用
Included angle of 3D vector
【Spark】. Explanation of several icons of scala file in idea
Awk tools
Wechat applet SetData dynamic variable value sorting
H5 video automatic playback and circular playback
Electron official docs series: Processes in Electron
Electron official docs series: Distribution
Solutions to the failure of last child and first child styles of wechat applet
计算两点之间的距离(二维、三维)
33、使用RGBD相机进行目标检测和深度信息输出
嵌入式virlog代码运行流程
shell脚本详细介绍(四)
Teacher Li Hang's new book "machine learning methods" is on the market! Purchase link attached
网络远程访问的方式使用树莓派