Why can’t I initialize a reference in an initializer list with uniform initialization?

Yes, its a bug. This is something new and was voted in the working paper in February 2012 (link). Nicol Bolas makes a good point in that gcc is actually the conforming compiler according to the FDIS approved C++11 standard because the changes to the working paper were made after that.

How does the number of braces affect uniform initialization?

Overload resolution is fun like this. {a} has exact match rank for initializing (a temporary for) the const A& parameter, which outcompetes the user-defined conversion B(const A&) as a realization of {a}. This rule was added in C++14 to resolve ambiguities in list-initialization (along with adjustments for aggregates). Note that the notional temporary is never … Read more

Does the C++ standard guarantee that uniform initialization is exception-safe?

It seems so: Curiously found in §6.6/2 Jump Statements [stmt.jump] of all places (N4618): On exit from a scope (however accomplished), objects with automatic storage duration (3.7.3) that have been constructed in that scope are destroyed in the reverse order of their construction. [ Note: For temporaries, see 12.2. —end note ] Transfer out of … Read more

Why doesn’t emplace_back() use uniform initialization?

Great minds think alike ;v) . I submitted a defect report and suggested a change to the standard on this very topic. http://cplusplus.github.com/LWG/lwg-active.html#2089 Also, Luc Danton helped me understand the difficulty: Direct vs uniform initialization in std::allocator. When the EmplaceConstructible (23.2.1 [container.requirements.general]/13) requirement is used to initialize an object, direct-initialization occurs. Initializing an aggregate or … Read more

Declaring a variable with two types: “int char”

It’s a mistake in the book. That is not a valid C++ declaration, even without the supposed narrowing conversion. It isn’t mentioned in any of the erratas on Bjarne Stroustrup’s page(4th printing and earlier), though, which is odd. It’s a clear enough mistake. I imagine since it’s commented with //error few people notice the mistake … Read more