Why does
std::vector<int> v{1,2,3};
for (int& e : v){
e = 5;
std::cout << e << std::endl;
}
compile fine, while
std::vector<bool> v2{false, false, false};
for(bool& e : v2){
if(e){
std::cout << "True\n";
}
}
creates a compile error
error: non-const lvalue reference to type 'bool' cannot bind to a temporary of type 'std::__1::__bit_iterator<std::__1::vector<bool, std::__1::allocator<bool> >, false, 0>::reference' (aka 'std::__1::__bit_reference<std::__1::vector<bool, std::__1::allocator<bool> >, true>')
The only thing that changes is the type from int to bool?