Email or username:

Password:

Forgot your password?
Gankra

looking at all the various ~new languages that want to be a successor to C++, i can't help but get the feeling that the most offensive thing to a C++ programmer is the existence of `const int&` due to generic interfaces

just absolutely seething at the idea of an indirected primitive

6 comments
Gankra

ye who write c++, what is thine feelings about std::vector<bool>?

Gankra

for those who don't know: it's standard (required?) for C++'s std::vector<bool> to be specialized to actually bitpack the booleans, getting you 8x the booleans per allocated byte (nice!)

...at the cost of any API that returns T* or the like now being literally impossible to satisfy, silently deleting random APIs from the std::vector interface (oh no!)

aiui this makes code that generically works with vectors now randomly incompatible with that particular substitution (unless you very carefully avoid those APIs)

for those who don't know: it's standard (required?) for C++'s std::vector<bool> to be specialized to actually bitpack the booleans, getting you 8x the booleans per allocated byte (nice!)

...at the cost of any API that returns T* or the like now being literally impossible to satisfy, silently deleting random APIs from the std::vector interface (oh no!)

Nicole

@Gankra I don't believe it's required to bitpack, but the APIs are required not to return a pointer so there's no reason not to.

Nicole

@Gankra fwiw, my opinion is "it's overhyped how terrible vector<bool> is, but it's certainly not good"

Gankra

@streganil i think that's where i fall too, yeah. vector<bool> is relatively rare, so it won't come up much, but it's unfortunate that a desire to optimize the concrete case of vector<bool> made the whole vector type just a little less useful in generic contexts

Ed Page

@Gankra @streganil

> a desire to optimize the concrete case

And it wasn't even created as an optimization but for pedagogical purposes.

> The vector<bool> specialization was intentionally put into the standard to provide an example of how to write a proxied container.

gotw.ca/publications/mill09.ht

Go Up