[cfe-dev] interesting c++ puzzle

Krzysztof Parzyszek kparzysz at codeaurora.org
Wed Jan 16 13:12:49 PST 2013


On 1/16/2013 3:04 PM, reed kotler wrote:
>
> This seems illogical to me. It does not call the copy constructor in
> 5.cpp but in 6.cpp it tails
> to compile because it can't find a valid copy constructor.

IIRC, according to the standard, this
   B b = f(1);
is equivalent to
   B b(f(1));

I suppose the compiler refuses to treat f(1) as an object of type B&, 
since it's a temporary.  Again, if I remember things correctly...

-Krzysztof


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation



More information about the cfe-dev mailing list