compiler-errors - 这是D错误吗?(无法访问私有模板参数)
问题描述
handled_record.d
:
module handled_record;
template CObjects(alias destructor) {
void f() {
destructor();
}
}
world.d
:
module world;
import handled_record;
private void free() { }
alias objects = CObjects!(free);
编译:
$ dmd -c *.d
handled_record.d(5): Error: function world.free is not accessible from module handled_record
world.d(7): Error: template instance `handled_record.CObjects!(free)` error instantiating
如果我删除private
关键字,错误就会消失。
它是编译器错误吗?(据我了解,传递给模板的别名符号应该可以被模板访问,因为它是显式传递给模板的,即使它是私有的。)
解决方案
推荐阅读
- bash - 入口点中的 Docker 运行脚本
- python-3.x - 识别列表中的空间数字
- amazon-ec2 - 将安装在 AWS EC2 实例上的 MySQL 与 AWS Glue 连接
- c# - Unity 和 Firebase 事务线程被捕获
- javascript - 是不是应该在调用函数之前声明函数表达式?那么为什么这段代码有效呢?
- javascript - Vue HOC 设置问题(使用 vue-compose)
- python - 使用 Python,如何将整个 xlsx 文件附加到 docx 文件中
- c# - 从不同 API 使用 IndetityServer4 中的 ConfigurationDbContext
- javascript - 避免 lodash 导入整个库并避免 _ 导致整个库加载
- node.js - Nodejs从谷歌电子表格中获取行返回对象未定义