soa 0.1.0

Struct Of Arrays template compatible with betterC


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

soa

A -betterC compatible Struct Of Arrays template for D.

It is available as a DUB package and may be used directly as a Meson subproject or wrap.

SOA types provide a dispatching object for member access, comparison, assignment and others, and also provides a Random Access Finite Range of those, allowing seamless substitution of Array Of Structs and Struct Of Arrays types.

Usage example

import soa;

// Transforms a struct definition like this
struct Vector2
{
    float x = 0;
    float y = 0;
}
Vector2[100] arrayOfStructs;

// To a struct definition like this
struct Vector2_SOA
{
    float[100] x = 0;
    float[100] y = 0;
}
Vector2_SOA structOfArrays;


alias Vector2_100 = SOA!(Vector2, 100);

Vector2_100 vectors;
vectors[0].x = 10;
assert(vectors[0].x == 10);
assert(vectors[0].x == vectors.x[0]);
vectors[1] = Vector2(2, 2);
assert(vectors[1] == Vector2(2, 2));

foreach(v; vectors[0 .. 2])
{
    import std.stdio;
    writeln(v.x, " ", v.y);
}
Authors:
  • gilzoide
Dependencies:
none
Versions:
0.2.0 2020-Dec-26
0.1.0 2020-Dec-26
~main 2020-Dec-26
Show all 3 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 17 downloads total

Score:
0.7
Short URL:
soa.dub.pm