When I compile this in clang 3.2
for(auto x : {1, 1.2}){}
I get an error like this:
error: cannot use type 'void' as a range
What does it mean?
You mixed your types in the initializer list. In this case it can be pretty clear, but don't forget
std::string foo;
for(auto x : {foo, "bar"}){}
Are also 2 separate types. There are of course plenty of other cases where you may expect it to work, but the types have to match exactly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With