Example:
template<class T> class A{
public:
A(){}
template<class U> A(A<U> &){}
private:
template<class U> A(A<U>&&){}
};
int main() {
A<int> a1;// legal
A<int> a2(std::move(a1));//legal. it calls implicitly-declared constructor.
}
but when I delete A(){}:
template<class T> class A{
public:
template<class U> A(A<U> &){}
private:
template<class U> A(A<U>&&){}
};
int main() {
A<int> a1;// illegal. 3
A<int> a2(std::move(a1));
}
- If template constructors didn't influence implicitly-declared-rules. why it becomes illegal?
- If template constructors influence implicitly-declared-rules, but why "A a2(std::move(a1));" legal?
Aucun commentaire:
Enregistrer un commentaire