Re: 'auto' and const references
Am 03.05.2013 15:16, schrieb Juha Nieminen:
> Let's say that a function returns a const reference. If I say this:
> auto x = thatFunction();
> what would the type of 'x' be? Will it be a const reference, thus
> eliding copying, or will a copy be made?
No, it's not. It's like template argument deduction for a parameter "T
x" where you pass in thatFunction(); as argument. So, x won't be a
> Is there any difference to these:
> auto& x = thatFunction();
> const auto& x = thatFunction();
Sure. But I think you can figure it out now.
|All times are GMT. The time now is 04:08 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.