c++ - 模板类友元函数的内部类
问题描述
解决方案
It's a non-deduced context.
Ostensibly you could have a definition like
template<typename AB>
bool operator == (const AB& b1, const AB& b2)
{
return b1.b == b2.b;
}
but it's too broad as it catches all types. Yoiy can restrict it this way
template<typename AB>
auto operator == (const AB& b1, const AB& b2) ->
std::enable_if_t<std::is_same_v<AB, typename A<decltype(b1.b)>::B>, bool>
{
return b1.b == b2.b;
}
推荐阅读
- node.js - 使用 NodeJS 在测试中从磁盘读取 - 同步与异步
- r - glmer使用哪个家庭?
- python - 在 TensorFlow 中手动设置梯度值并在反向传播中使用它们
- javascript - Vue.js 中的意外令牌“导出”
- c# - 从 EF Core 2.1 升级到 3.1 后无法在项目之间进行数据库迁移
- python - 将新的 csv 数据与主数据进行比较,并从新的 csv 中删除重复项,并从文件中获取已清理的 csv 数据
- nativescript - 在 Windows 上将 Nativescript 应用程序作为桌面应用程序运行
- r - 如何使用变量对 data.frame 列进行子集化?
- windows - 为什么 Windows 命令 DIR 在搜索 *.tif 文件时也会输出 *.tiff 文件?
- ios - 使图像更小,作为我的视图层的内容添加