c++ - 模板之外的复制赋值运算符
问题描述
我有一堂课
class A : public B
{
public:
// 1st copy assignment with parameter pack
template<class Arg>
A& operator=(Arg&& arg)
{
B::operator=(std::forward<Args>(arg));
return *this;
}
// 2nd copy assignment with const A&
A& operator=(const A& arg)
{
// some code
}
};
第二个不要求以下
A a, b;
a = b;
如何让编译器为上述代码调用第二个?
解决方案
推荐阅读
- keycloak - 基于资源的RBAC实现思路
- node.js - 在 Sequelize 中创建模型引用关联
- java - Apache Camel 优雅关闭 Oracle AQ 上的长时间接收超时
- typescript - Typescript:什么是映射类型,它有什么用?
- ruby-on-rails - Laravel Passport:独立的授权服务器和资源服务器
- excel - Excel 365 for MAC 工作簿激活方法行为不端?
- c++ - 程序接受输入的第一个字符,即使它是无效的
- node.js - 查看 BIM 360 和 Fusion Models_Forge 教程
- docker - 无法在 docker for windows 中提供 sysctl 选项
- bash - “Bash@3”到底是什么意思?