[–] 5 points 2 months ago

Just quoting from the introduction:

hive is a formalisation, extension and optimization of what is typically known as a 'bucket array' container in game programming

The concept of a bucket array is: you have multiple memory blocks of elements, and a boolean token for each element which denotes whether or not that element is 'active' or 'erased', commonly known as a skipfield. If it is 'erased', it is skipped over during iteration. When all elements in a block are erased, the block is removed, so that iteration does not lose performance by having to skip empty blocks. If an insertion occurs when all the blocks are full, a new memory block is allocated.

It seems a little similar to a std::deque with the addition of flags to mark elements as erased to avoid reallocating blocks.
The main advantage is stable references and iterators with minimal extra allocations/deallocations.

I've built similar structures in my own game engine where I keep a sorted list of free indexes, so new entries fill up the earliest free index, and on average the empty entries stay at the end with valid entires staying packed together in contiguous memory at the beginning.

  • source
  • parent
  • context
  • [–] 2 points 5 months ago

    The common thread is that all of these books are published by Larson and Keller. I guess they can’t be bothered to spend time crafting a blurb that suits the book, so they just use the same blurb template for all of their books.

    Let’s be honest with ourselves: isn’t one of the goals of programming to make the code as reusable and generic as possible.

    Kinda fitting for a C++ book. 🤷‍♂️

  • source
  • [–] 5 points 5 months ago* (4 children)

    What I'm looking for is a solid open-source C++ project where GenAI was a big part of the development process. So far, nothing like that. At this point, vibe coding feels like it exists mostly as a buzzword, while real vibe-coded C++ projects simply don't. Or are they hiding somewhere, too ashamed to be seen? :)

    I'm not aware of any.

    I guess I'm not shocked. C++ isn't known for pandering to idiocy.

    Edit: Contrasted to Visual Basic, which I love, and which is arguably harder to write outright non-functional code in.

  • source
  • [–] 1 point 6 months ago

    Yeah. References feel like they were originally made to be safer but any safety the could have provided got sacrificed to the compiler for a little more speed, leaving them more dangerous than pointers with the illusion of safety.

    That said, compilers are starting to get support for more hardening options now that c/c++ has to care about memory safety, I imagine this might be partially covered by that eventually (eg crash when assigning null to a reference, there's realistically no saving dangling references though)

  • source
  • parent
  • context
  • [–] [S] 2 points 7 months ago

    Yeah I didn't mean a one-to-one implementation in the pedantic sense; I meant more like how it would be implemented to address certain issues in C++ that I demonstrated at the beginning. Sorry if I wasn't clear with the article.

  • source
  • parent
  • context
  • [–] 1 point 7 months ago (1 child)

    I didn't read your post. But note that ? depends on traits /type classes with associated types (Try, FromResidual, and From), and is often implemented for sum types (e.g. Result, Option) with at least two variants containing Output and Residual type values.

    The FromResidual part does value conversion for the Residual, which is how you e.g. get auto-converted error values matching the return Result value. These converted error values are often themselves contained in variants in an enum/sum Error type.

    So neither an actual equivalent in C++ is possible, due to type system limitations/differences, nor whatever you tried to do is an apples-to-apples match, or even represents two fruits from the same basket.

  • source
  • [–] [S] 1 point 7 months ago

    This is the first article that I write of this type, so I tried to create a balance between implementation and explanation without making the latter strictly dominate the pacing. If anyone has feedback I'd appreciate!

  • source
  • [–] [S] 3 points 8 months ago

    Same, tend to avoid Boost wherever I can. Or at least, avoid most of their utilities. Boost.Config standalone seems to serve some good purposes, and there are like 3 or 4 tools that are in Boost that also function properly standalone (most notably, Boost.Nowide).

  • source
  • parent
  • context
  • view more: ‹ prev next ›