当前位置:网站首页>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))
知道如何分解的时候,就容易搞懂了.
边栏推荐
- Beifu PLC realizes zero point power-off hold of absolute value encoder -- use of bias
- Reprint - easy to use wechat applet UI component library
- Solutions to the failure of last child and first child styles of wechat applet
- Log in to the server using SSH key pair
- MySQL数据库讲解(四)
- HDU 3709 Balanced Number
- Generate JDE dot train
- Oplg: new generation cloud native observable best practices
- [how to connect the network] Chapter 2 (Part 1): establish a connection, transmit data, and disconnect
- Guruiwat rushed to the Hong Kong stock exchange for listing: set "multiple firsts" and obtained an investment of 900million yuan from IDG capital
猜你喜欢

I met the problem of concurrent programming in an interview: how to safely interrupt a running thread

Cloudcompare - Poisson reconstruction

Create your own cross domain proxy server

HW蓝队溯源流程详细整理

Oplg: new generation cloud native observable best practices

Teacher Li Hang's new book "machine learning methods" is on the market! Purchase link attached

三维向量的夹角

免费的机器学习数据集网站(6300+数据集)

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

awk工具
随机推荐
MySQL数据库讲解(五)
NVM installation tutorial
Es6: iterator
A few lines of code can realize complex excel import and export. This tool class is really powerful!
使用 Performance 看看浏览器在做什么
KITTI Detection dataset whose format is letf_ top_ right_ bottom to JDE normalied xc_ yc_ w_ h
HW蓝队溯源流程详细整理
MySQL数据库讲解(三)
ES6 module
[how to connect the network] Chapter 2 (middle): sending a network packet
shell脚本详细介绍(四)
Oplg: new generation cloud native observable best practices
Postman自动化接口测试
Thinking caused by the error < note: candidate expectations 1 argument, 0 provided >
Common faults of MySQL database - forgetting database password
Chapter 10 setting up structured logging (2)
What features are added to Photoshop 2022 23.4.1? Do you know anything
Electron official docs series: Examples
Beifu PLC realizes data power-off maintenance based on cx5130
去某东面试遇到并发编程问题:如何安全地中断一个正在运行的线程