C++11 has given us initialiser lists. I've learned that these do not perform narrowing conversions, which sometimes breaks compilation of existing code, for example when operating on enum values with implicitly int-widened values:
enum COMMAND { COMMAND_WRITE_MISC_CONFIG = 0x70 }; struct CommandSettings { quint8 buddy; }; void NarrowingTest::testNarrowing() { quint8 i = 100; CommandSettings test{static_cast<quint8>(COMMAND_WRITE_MISC_CONFIG | i)}; quint8 x = COMMAND_WRITE_MISC_CONFIG | i; QVERIFY(true); } The initialisation of test wouldn't compile without the cast.
What I'm looking for is the rationale behind the assignment initialisation of x still working.
CommandSettings test = {COMMAND_RITE_MISC_CONFIG | i};though, that's valid C++03 but made an error as of C++11, and can be made valid C++11 by adding a cast.