Namespaces
Variants
Views
Actions

Talk:cpp/language/reference initialization

From cppreference.com

What about initializing a non-static class member of reference type? Is that also reference initialization, and if so, does this page need extending?

good catch, I think it should be here even if I am not finding anything specific about references in 12.6.2 (it only talks of member subobjects, which reference members are not) --Cubbi (talk) 06:58, 16 June 2015 (PDT)
added. --Cubbi (talk) 06:56, 2 July 2015 (PDT)

I am wondering about the lifetime extension exception case:

  • a temporary bound to a return value of a function in a return statement is not extended: it is destroyed immediately at the end of the return expression. Such function always returns a dangling reference.

I suppose that an example might be:

std::string && foo() { return std::string("bar"); }

Tmcleod (talk) 13:27, 25 April 2016 (PDT)