if I have a function:
Foo& Bar()
{
return /// do something to create a non-temp Foo here and return a reference to it
}
why is this:
The type deduction for auto works exactly the same as for templates:
auto you will get a value type.auto& you wil get a non-const reference typeconst auto& you will get a const referenceauto&& you will get
Taken directly from Herb Sutter's blog post:
auto means “take exactly the type on the right-hand side, but strip off top-level const/volatile and &/&&.”