Multiple ChoiceIntermediate 45s
vector<bool> proxy reference
Why can `auto b = v[0];` on a `std::vector<bool>` be surprising?
Options
- 1It deduces a bitfield that cannot be used inside an if-statement, so the comparison silently returns false.
- 2It deduces a proxy `std::vector<bool>::reference` object (a bit reference), not `bool`, so `v[0]` behaves differently from other vectors.
- 3vector<bool> is not allowed by the standard at all and will not compile in any conforming compiler implementation.
- 4It returns a pointer to a single bit that is not addressable, so dereferencing it results in a compile error.
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.