In his talk about CppCon 2014, “Type Subtraction and Why You Care,” Scott Meyers raises the question of why there is a special rule for auto and compressed initializers in the C ++ 11 / C ++ 14 standard (his question starts at 36m05s ).
The semantics of a car in combination with a bit-init list are defined in §7.1.6.4 / 6.
I thought about it and could not find a use case. The closest I've seen so far is one example where Bjarne Straustup used it.
In their Cpp 2014 they say "Making simple tasks easy!" , it once uses auto to capture initializers (but only as a workaround).
Here is the code (part of slide 30, at 37m10s ):
// auto ss1 = collect({ 1, 2, 3, 4, 5, 6 }, odd); // error: Bummer! auto lst = { 1, 2, 3, 4, 5, 6 }; auto ss2 = collect(lst, odd); // {1,3,5}
But note that this is just a workaround. He noted that this is not necessary. Instead, he would prefer to pass arguments to the function directly. Therefore, this may not serve as a good motivation for auto and initializer lists.
My understanding of C ++ is not deep enough to judge the lower bounds of the permissions of initializer lists in the Bjarne example, as he suggests. In any case, to avoid the need for auto in this case.
So, auto and the initializer list only a workaround for something that could be better solved? Or are there good examples where the additional rule of automatic deduction in §7.1.6.4 / 6 is useful?