'Can not general copy constructor in class template be defaulted?
In the following program struct template A has a constructor from const A<int> &. For A<int> it should be copy-constructor, which can be defaulted:
template<typename T>
struct A {
A() {}
A(const A<int> &) = default;
};
int main() {
A<int> a;
}
This program is accepted by Clang, but both GCC and MSVC reject it with the error:
error C2610: 'A<T>::A(const A<int> &)': is not a special member function or comparison operator which can be defaulted
note: see reference to class template instantiation 'A<T>' being compiled
Demo: https://gcc.godbolt.org/z/Mn6nMbe1x
Which compiler is right here?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
