Assuming I have the following (invalid) code:
struct A { A(A) {}; };
MSVC gives me:
error C2652: 'A' : illegal copy constructor: first parameter must not be a 'A'
Why does the compiler detect this as a copy constructor, and not a regular constructor?
Chapter 12.8.2 of the C ++ Standard states:
A constructor without a template for the X class is a copy constructor if its first parameter is of type X & , const X & , mutable X & or const volatile X &
I would expect the compiler to detect the above method as a regular constructor, like
struct A { A(B) {}; };
whereas B is a different class.
Where is this behavior defined?
c ++ language-lawyer
tobspr
source share