C++11/14 and return( ... ) vs return

Posted by user2485710 on Stack Overflow See other posts from Stack Overflow or by user2485710
Published on 2014-06-09T13:50:15Z Indexed on 2014/06/12 21:25 UTC
Read the original article Hit count: 157

Filed under:
|
|
|
|

In C++ you are allowed to write a return statement that looks like :

return ( ... );

which is different from the more popular :

return ... ;

In particular the first version returns the address/reference of something that is local to the stack of the function which contains that return statement.

Now why something would like to return a reference to something that, at that point, has no lifetime ?

What are the use case for this idiom ? Considering the new buzzword and features from C++11 and C++14 there is a different usage for this ?

© Stack Overflow or respective owner

Related posts about c++

Related posts about c++11