Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is vector<bool> violating container requirements?

C++ standard draft n3242 in 23.2, in table containing container requirements, states that X::reference for container containing T must be lvalue T. Yet, for vector<bool>, vector<bool>::reference is another class, a proxy for accessing individual bits of bytes stored in vector.

Does that mean that std::vector class template specification for T = bool, defined in standard, fails to fulfill container requirements?

like image 660
Griwes Avatar asked Nov 30 '22 02:11

Griwes


1 Answers

Does that mean that std::vector class template specification for T = bool, defined in standard, fails to fulfill container requirements?

Yes.

Similarly, its iterators are not truly random access iterators, because operator* yields a proxy object.

vector<bool> is a mess.

like image 154
James McNellis Avatar answered Dec 06 '22 20:12

James McNellis