Readit News logoReadit News
s5ma6n · a year ago
Also relevant and useful single-file public domain libraries for C/C++

https://github.com/nothings/stb

HexDecOctBin · a year ago
Here's a master list of most libraries like this: https://github.com/r-lyeh/single_file_libs
amadio · a year ago
I was just taking a look and couldn't help but notice the switch statement for your operator[], which likely causes a lot of unnecessary bad speculation at runtime:

https://github.com/RandyGaul/cute_headers/blob/755849fc2819d...

I fixed this exact problem in a highly used library in high energy physics:

https://gitlab.cern.ch/CLHEP/CLHEP/-/commit/5f20daf0cae91179...

Many believe the C++ compiler will magically optimize the switch away, but in some cases, like the example above for CLHEP, it doesn't happen, so you end up with bad performance.

amadio · a year ago
Since you left this "optimize me" comment here:

https://github.com/RandyGaul/cute_headers/blob/755849fc2819d...

See an optimized quaternion multiplication implementation in SSE by me here:

https://stackoverflow.com/questions/18542894/how-to-multiply...

test1235 · a year ago
randy's also written the cute framework and is super helpful on discord, if you're into that sorta thing.

I'm sure I've also spotted him in the SDL channels.

https://github.com/RandyGaul/cute_framework

quotemstr · a year ago
Amazing how the same people will go nuts for header-only C++ libraries, but the moment you involve an .a file, say "Noooo! you can't just vendor your dependencies! You need eight zillion apt dependencies!"

Header-only libraries are static linking.

ndriscoll · a year ago
Container images are also just a worse version of static linking (giving you all of the downsides and missing several upsides). Ideally the industry moves to something like nix for most purposes, and static linking is used for embedded systems and teaching.
malkia · a year ago
These do not seem to be pure "header-only", but involve #include-ing the same file at least once with "#define C2_xxx_IMPLEMENTATION 1"

That's fine though. AFAIK, there is no sane way (across platforms) to have singletons, and that involves some of the the trick above, unless you know someother way

If you do, please add your idea here - https://github.com/open-telemetry/opentelemetry-cpp/issues/2... - "Header only singletons are not working properly for Windows #2534"

steeleduncan · a year ago
> Professional level 3D vector math

I'm always suspicious of "Professional" in descriptions like this as it is a meaningless word you add to make it sound impressive.

Also, in this case it means a 900 line math library with 78 lines of tests...

AlotOfReading · a year ago
The library is mostly a wrapper around intrinsics, so it's not doing much that would necessitate testing if the author is experienced enough.

The fact that invert_safe() isn't actually safe isn't the greatest look here though.

samiv · a year ago
self grandstanding is what it is.
Alifatisk · a year ago
How does one aquire one of these one-file libraries and keep it updated? Is there an package manager for something like this? Can I use pacman?
elpocko · a year ago
These libraries are not compiled, packaged or distributed on their own; you have to include their code directly as part of your C/C++ game or app. You acquire and update them using git.
rickstanley · a year ago
And if not using git, just fiddle around with a scripting language to automate the update, like check github's release API to see if there was some change between your local and the remote version somehow.
ndriscoll · a year ago
These are meant to be vendored by your project, so git submodules are a natural way to do that.