当前位置:网站首页>D template error with different types
D template error with different types
2022-07-23 09:54:00 【fqbqrr】
module foo;
mixin template opBi(A, A function(A, A)[string] f0,){
static foreach (k, f; f0) {
A opBinary(string op: k)(A r) {
return f(this, r); } }
}
struct A {
mixin opBi!(
A, [ "+": (A a, A b) => a],
);
}
struct B {
mixin opBi!(
B, [ "+": (B a, B b) => a],
);
}
You can delete Some types And use typeof(this). Come on Pass on Correct type to f0.
module foo;
mixin template opBi(alias f0){
static foreach (k, f; f0) {
typeof(this) opBinary(string op:k)(typeof(this) r) {
return f(this, r); } }
}
struct A {
mixin opBi!(
[ "+": (A a, A b) => a],
);
}
struct B {
mixin opBi!(
[ "+": (B a, B b) => a],
);
}
Incoming AA The type is T1[string], And the expectation is T2[string], among T1:B function(B, B) pure nothrow @nogc @safe,T2:B function(B, B).
边栏推荐
- Redis 6.0源码学习 Simple Dynamic String
- ES6 related interview question 3
- 中信期货网上开户是否安全,网上开户会被骗吗?
- Self assignment and abnormal security problems in operator=
- 清华、AIR、腾讯 | 3D等变分子图预训练
- PHP RSA 生成公钥私钥 PSA2 加密解密
- Peptide nucleic acid coupled polypeptide ile Glu Gly Arg PNA (s-2222) | BOC Leu Gly Arg PNA
- QML(17)——读写txt文件
- MySQL数据库提权学习
- 每周推荐短视频:为什么会写这样一本书?
猜你喜欢

Tensorflow 2.0深度学习教程

PNA modified polypeptide BZ Val Gly Arg PNA | BOC Val Leu Gly Arg PNA

可视化全链路日志追踪

phpcms实现产品多条件筛选功能

隐藏网站服务器响应头中 PHP 版本信息

构建一个CPU模拟器

ADAS测试方案

How to determine the end point of a software test

Peptide nucleic acid coupled polypeptide ile Glu Gly Arg PNA (s-2222) | BOC Leu Gly Arg PNA

分库分表真的适合你的系统吗?聊聊分库分表和NewSQL如何选择
随机推荐
构建一个CPU模拟器
【洛谷】P1972 HH的项链
【Node基础入门】----node中间层做接口转发,实现跨域请求
MySQL数据库UDF提权学习
每周推荐短视频:为什么会写这样一本书?
The difference between MySQL key and index and the creation and deletion of indexes
9.2章MATLAB的程序控制
Adas test plan
百度地图鹰眼轨迹服务
LeetCode 提供的main函数中 JsonArray 所使用的jar包
TDengine 助力西门子轻量级数字化解决方案 SIMICAS 简化数据处理流程
Is it safe for CITIC futures to open an account online and will it be cheated?
如何做好陪同翻译的工作
清华、AIR、腾讯 | 3D等变分子图预训练
第一次改开源中间件keycloak总个结
Burpsuite 插件的学习与使用
canal 03 (共8章)
d类型不同的模板错误
C语言课设----个人信息管理系统(包含学生成绩和消费记录)
CAD如何绘制带有弧形的箭头