I came across a curious line of code of the form:
// Given the following definitions:
class B;
B b;
// Line of interest:
auto a(b);
I thought it must be a typo, but after some experimentation found out that it works, and seems to always call the copy constructor of the type of b
(even if you have other classes that can also have a matching constructor, and even if you additionally delete the copy constructor for the type of b
).
I don't know the technical name of such a statement, so I'm not sure how to search for it in cppreference or StackOverflow. How does the compiler parse this type of statement in general, and where is it documented?
--
Re: duplicate marking. I don't see how they've addressed this construct. I already know auto
uses template type deduction, that doesn't clarify anything in this case.