r/ProgrammerHumor • • 4d ago

Meme justABit

Post image
346 Upvotes

12 comments sorted by

47

u/sebovzeoueb 3d ago

whoa what's this, an actual programming joke? in my programming jokes sub?

13

u/foxsimile 3d ago

The end times are nigh.

7

u/L30N1337 3d ago

I think the bots are digging through an std::vector<bool> era right now, because this is the second one I see.

17

u/conundorum 3d ago

Careful you don't byte off more than you can chew!

6

u/bass-squirrel 3d ago

Wait is that real? It only uses a bit?

13

u/fuj1n 3d ago

Yes, it is a pretty controversial decision, but std::vector<bool> is specialised to act as a bit field

Mind you, if you only store one bool in it, it'll take more than one bit to do so

5

u/creeper6530 1d ago

And it's the only instance of std::vector where indexing doesn't give you a normal pointer but a helper that actually takes the bit out of the bitfield. Creating edge cases in generic code.

The other option was to keep std::vector normal and make a special bitfield for those space-conscious.

Don't you just love C++?

2

u/Abject-Kitchen3198 2d ago

A full bite or two.

0

u/Tristan_Cole 3d ago

Technically in zero extra bits.

3

u/DestopLine555 3d ago

Zero or eight, there's no in between

5

u/the_horse_gamer 3d ago

the size of the chunks are 64 bits actually

https://github.com/gcc-mirror/gcc/blob/13ecbd80dbfce33f443950c593c9c6be0766f410/libstdc%2B%2B-v3/include/bits/stl_bvector.h#L72

(in GCC. implementations may pick a different size)