How does user deleted auto constructors affect implicit generation of copy constructors? For eg:
struct Foo {
Foo(X) = delete;
auto operator=(X) = delete;
};
int main() {
Foo a;
Foo b(a);
b = a;
}
In the above struct, if X is auto
, const auto&
or const auto&&
then the compiler still generate the copy constructor and copy assignment operator, and hence the code is being compiled and executed completely fine.
But if X is auto&
or auto&&
then compiler will not generate the copy constructor and copy assignment operator, and I'm getting 'use of deleted function' error.
I have tried in GCC, Clang and ICC (unfortunately MSVC doesn't support auto parameters still), and same behavior is observed in all three. So, I guess it is somewhere defined in the standard.
Which standard rule guides the aforementioned behavior of compilers?