当前位置:网站首页>d违反常了吗
d违反常了吗
2022-07-30 21:46:00 【fqbqrr】
import std;
struct S
{
string s;
void delegate(string s) update;
}
void func(const S* s)
{
//函数接收S常引用,它不能修改S
writeln(*s);
s.update("func");//函数调用闭包的可变引用,来修改.相当于`两层`间接.
writeln(*s);
}
void main()
{
auto s = S("test");
s.update = (_) {
s.s = _; };
//闭包可以修改数据.它持有`可变`引用
writeln(s);
func(&s);
writeln(s);
}
//输出是:
S("test", void delegate(string))
const(S)("test", void delegate(string))
const(S)("func", void delegate(string))
S("func", void delegate(string))
常表示我不改,不变表示不会变.
边栏推荐
- JDBC (detailed explanation)
- 基于ABP实现DDD--实体创建和更新
- 基于ABP实现DDD--领域服务、应用服务和DTO实践
- Uni-app 小程序 App 的广告变现之路:激励视频广告
- 【科研】文献下载神器方式汇总
- About the error of SFML Rect.inl file
- How do I refresh the company's background management system (Part 1) - performance optimization
- Solve npm warn config global `--global`, `--local` are deprecated. use `--location=global` instead
- Motion Tuned Spatio-temporal Quality Assessmentof Natural Videos
- 你需要知道的ES6—ES13开发技巧
猜你喜欢

【信息安全技术】RSA算法的研究及不同优化策略的比较

【Nacos】解决Nacos下载速度缓慢的问题

TransGAN code reproduction - Jiutian Bisheng Platform

IDEA2021.2安装与配置(持续更新)

MYSQL JDBC图书管理系统

面试难题:分布式 Session 实现难点,这篇就够!

openim支持十万超级大群

It is enough for MySQL to have this article (disgusting typing 37k words, just for Bojun!!!)

MySQL 5.7 detailed download, installation and configuration tutorial

Apache DolphinScheduler新一代分布式工作流任务调度平台实战-
随机推荐
MySql 5.7.38下载安装教程 ,并实现在Navicat操作MySql
共用体、共用体与结构体的区别、枚举之C语言犄角旮旯的知识
关于MySQL主从复制的数据同步延迟问题
The Road to Ad Monetization for Uni-app Mini Program Apps: Rewarded Video Ads
go慢速入门——函数
【零代码工具】15 款企业级零代码开发平台推荐,总有一款是你心仪的
ClickHouse 创建数据库建表视图字典 SQL
【高等数学】矩阵与向量组的秩和等价
mysql 时间字段默认设置为当前时间
【网络安全专栏目录】--企鹅专栏导航
The mysql time field is set to the current time by default
Solve npm warn config global `--global`, `--local` are deprecated. use `--location=global` instead
MySQL 游标
ELF: Loading process
JUC原子类详解
Niu Ke Xiaobaiyue Race 53 A-E
2022/07/30 学习笔记 (day20) 面试题积累
Deep Non-Local Kalman Network for VideoCompression Artifact Reduction
DistSQL 深度解析:打造动态化的分布式数据库
ArrayList扩容机制分析