Topic: C++0x uniform initialization and backwards compatibility
Author: Scott Meyers <usenet@aristeia.com>
Date: Tue, 5 May 2009 14:09:36 CST Raw View
I'm trying to understand uniform initialization, and I'm a bit
confused about backwards compatibility. As I understand it,
initialization of nested aggregates need not reflect the nested
structure in the initialization list:
struct Point { int x, y; };
Points points[] = { 1, 2, 3, 4 }; // Array of 2 elements,
// Point{ 1, 2} and Point {3, 4}
Per N2532, this is for backwards compatibility. Fine, simple enough.
But it seems to clash with the lack of backwards compatibility for
initialization lists where narrowing would occur. This example is
from the draft standard:
int ai[] = { 1, 2.0 }; // error: narrowing
Together, this means that old aggregate initialization code dependent
on the lack of proper nesting in an initialization list will continue
to compile, but the same old code that's dependent on traditional C
narrowing conversions will not. This leads me to wonder what the
basic policy on backwards compatibility wrt brace initialization is.
Can somebody explain it to me?
Thanks,
Scott
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]