我有一个使用通用引用的带有ctor的human类
class Human {
public:
template<typename T>
explicit Human(T&& rhs) {
// do some initialization work
}
Human(const Human& rhs); // the default ctor I don't care about
}
现在如果我有一个常量人类对象
const Human one_I_do_not_care; // then play with that
Human the_human_I_care(one_I_do_not_care) // now create another one
最后一行是使用模板ctor还是默认ctor?我的理解是“const”将取消模板ctor的资格,对吗?
Human the_human_I_care(one_I_do_not_care) // line in question
const取消模板ctor的资格,我的意思是添加const之后它将与模板ctor不匹配,不是它仍然匹配两个,而是编译器选择一个。