Get the latest tech news

Implementing a Struct of Arrays


Recently, I watched Andrew Kelley’s talk on Practical Data Oriented Design. It goes into some of the architectural changes he’s been making to the Zig compiler, with pretty significant performance benefit. Would definitely recommend checking out the talk, even if you’re like me and have never written any Zig.

That would actually be simpler if I used std::construct_at, since I wouldn’t need to determine M. But in general I prefer placement new (especially since that’ll be constexpr in C++26 too) since it can do all kinds of initialization. One nice thing Zig has going for it is that, as a C language, you can just construct an undefined object and then piece-wise assign the members. This may prove difficult in C++ for a number of reasons, but I think it’s worth considering — especially as we’ll want to pursue more code generation utilities.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of arrays

arrays

Photo of Struct

Struct

Related news:

News photo

A soft exoskeleton was designed with integrated tactile sensor arrays that were used for ‘feeling’ the differences between right & wrong versions of a song played on the piano. The device demonstrated high classification accuracy & could be used to guide disabled people on customized rehab programs.

News photo

Researchers Develop Arrays of Tiny Crystals That Deliver Efficient Wireless Energy