Consider the following snippet:
#include
#include
#include
int main()
{
std::vectorv = {
I assume the first lambda might return int or int&¹. Not const int& as the reference v is not to a const object (it doesn't matter that the capture itself is not mutable, since that's the reference itself)
Life times of temporaries get extended to the end of the enclosing scope when bound to a const-ref
¹ I'll try to dive into that later. For now, I'm going with regular deduction intuition and say that auto would decuce int, whereas auto& would deduce int&, so I expect that the actual return type is int. If anyone beats me to it, all the better. I won't have time for a few hours
See the test supplied by @milleniumbug: Live On Coliru