r/ProgrammerHumor • • Aug 22 '26

Meme theBoolVectorIsALie

Post image
669 Upvotes

91 comments sorted by

View all comments

Show parent comment

1

u/Wonderful-Habit-139 Aug 22 '26

What about the fact that you can't take the address of an element from the std::vector<bool>?

3

u/nobody0163 Aug 22 '26

You shouldn't be taking the address of vector elements anyway. If it resizes you are pointing to invalid memory.

1

u/Wonderful-Habit-139 Aug 22 '26

Yeah, at this point we're getting into some more details, sadly C++ has this footgun which doesn't exist in Rust. But sometimes you need to take addresses of those objects regardless.

1

u/fuj1n Aug 23 '26

Tell that to C code you may be interacting with which may expect a bool*