f



uniform initialization of temporary reference

{ edited by mod to shorten lines to ~70 characters. -mod }

consider the following code

int x;
using intref = int&;
intref w{x}; // A
intref{x}; // B

now, line A compiles correctly both in clang and gcc ( it didn't as of
c++11, defect fixed in c++14 AFAIK )

the problem is line B: clang treats it the way one would expect
( a temporary reference is bound to x ) whereas gcc 4.9 treat it in
the old defected way ( a temporary of type int is created and bound to
the reference, resulting in a compiler error ).

Who's right here ? thank you


-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
MJanes
5/17/2016 6:29:10 AM
comp.lang.c++.moderated 10738 articles. 1 followers. allnor (8509) is leader. Post Follow

0 Replies
300 Views

Similar Articles

[PageSpeed] 57

Reply: