删除的操作员隐藏了类操作员
deleted operator hides class operator?
我在重新访问和更新任何旧库时发现了一个非常奇怪的问题。我有以下代码
class bmint_tmp;
class bmfloat_tmp;
template<typename T> struct bop_return{typedef bmint_tmp type;};
template<> struct bop_return<float>{typedef bmfloat_temp type;};
class bmint
{
template<typename T> friend typename bop_return<T>::type operator+(const T& l, const bmint& r);
/** irrelevant code **/
};
template<typename T> typename bop_return<T>::type operator+(const T& l, const bmint& r)
{
return r.operator+(l);
}
template<> typename bop_return<bmint_tmp>::type operator+(const bmint_tmp& l, const bmint_tmp& r)=delete;
我删除了此模板实例化,因为我更喜欢被称为现有的bmint_tmp :: operator ,在另一个文件中以成员方法的形式实现。但是,在编译时,似乎海湾合作委员会除了删除了操作员外什么都没有看到,并说:错误:使用已删除函数'typeName :: BigMath :: Bop_return :: type bigmath :: operator (const t&amp;,const bigmath :: bmint&amp;)[带有t = ... >我试图更改修饰符(例如,删除const规范),但是我的许多尝试都没有成功。谁能帮忙?预先感谢。
是的,如果删除了一个函数,则它仍然存在(甚至被认为是定义的!),所有内容都暗示&Hellip;您实际上无法称呼它。
使用enable_if
,而是根本无法实例化模板专业化。那么唯一的候选人将是您想要的操作员功能。
相关文章:
- 这是我尝试让用户将值输入到数组中.然后将其隐藏为大量的星号
- <<操作员在下面的行中工作
- 结构和双指针隐藏在其他结构中,多层混淆
- C++ 与操作员不匹配<<
- 操作员C++的模棱两可的过载
- 在 cpp 文件中隐藏采用模板参数引用的方法
- C++中>>操作员过载时出现问题?
- NaN 上的宇宙飞船操作员
- 参数包构造函数在类模板中隐藏用户定义的转换
- 如何等待窗口隐藏在Qt中?
- 如何使用类型别名从模板化类中隐藏模板列表
- 在设计 SDK 时,我是否应该在 C++ 头文件中完全隐藏内部类?
- 比根<操作员
- SFINAE不能防止模棱两可的操作员过载吗?
- 什么是现实中的"endl"(或任何输出操纵器)?它是如何实现的,它如何与操作员<<一起工
- 名称隐藏对静态函数继承的实例使用
- 在 Linux 中使用 ioctl() 获取隐藏功能报告时,零字节消失
- 从多个模板化基类派生时出现"隐藏重载的虚函数"警告
- 如何在 Omnet++ 5.6.1 中隐藏箭头?
- 删除的操作员隐藏了类操作员