Structure-of-array synthesis in C++20

Overview

ahsohtoa - automatic AoS-to-SoA

C++ Sponsor License Platforms

Automatic structure-of-array generation for C++20: this library takes a structure such as:

struct Foo {
  int a;
  float b;
  struct Bar {
    float x;
    char y;
  } c;
};

and, given:

ahso::arrays
    storage_direct;

ahso::recursive_arrays
   
     storage_recursive;
   
  

will respectively synthesize types which look like:

// for storage_direct: 
std::tuple
   <
   int>, std::vector<
   float>, std::vector
   
    >


    // for storage_recursive: 
std::tuple
    
     <
     int>, std::vector<
     float>, std::vector<
     float>, std::vector<
     char>> 
    
   
  

Dependencies

  • Boost.PFR
  • C++20

Simple example

(index).position.x = 2; // Or if the proper type is provided (until we get metaclasses, see example): e[index].physics.position.x = 2; // Remove an entity e.erase(index); } ">
struct vec3 { float x,y,z; };
struct color { float r,g,b,a; };
struct physics_component {
  vec3 position;
  vec3 speed;
  vec3 acceleration;
};

struct render_component {
  color col;
};

struct entity {
  physics_component physics;
  render_component render;
}

int main()
{
  // Define our storage
  ahso::arrays
    e;

  
   // Preallocate some space like you would with std::vector
  e.
   reserve(
   1000);

  
   // Add a new entity
  
   auto 
   index = e.
   add_entity({
    .
   physics {
      .
   position { 
   0., 
   0., 
   0. }
    , .
   acceleration { 
   1., 
   0., 
   0. }
    },
    .
   render {
      .
   col { 
   0., 
   1., 
   0., 
   1. }
    }
  });

  
   // Access a specific component for entity "index"
  e.
   get
   
    (
    index).
    position.
    x = 
    2;
  
  
    // Or if the proper type is provided (until we get metaclasses, see example): 
  e[
    index].
    physics.
    position.
    x = 
    2;

  
    // Remove an entity
  e.
    erase(
    index);
}
   
  

Example with all the features

See https://github.com/celtera/ahsohtoa/blob/main/tests/test.cpp !

Licensing

The library is licensed under GPLv3 + commercial.

You might also like...
Total 21 math problem solved by c language with 4 types of functional reference. Also added circular repeated linked list system of Data structure.

C-ProblemSolve Total 21 math problem solved by c language with 4 types of functional reference. Also added circular repeated linked list system of Dat

🏅State-of-the-art learned data structure that enables fast lookup, predecessor, range searches and updates in arrays of billions of items using orders of magnitude less space than traditional indexes

The Piecewise Geometric Model index (PGM-index) is a data structure that enables fast lookup, predecessor, range searches and updates in arrays of bil

Typesafe, Generic & Fastest Set Data structure implementation in C
Typesafe, Generic & Fastest Set Data structure implementation in C

Typesafe & Fast as fuck Set in C Key Features Extremely fast non-cryptographic hash algorithm XXHash Complete Typesafe APIs Double Hashing to avoid bo

A simple & stupid data structure library for C

HDataStruct - Hans' Data Structures Library A simple & stupid data structure library for C. Introduction This is a small C library containing several

Hashmap data structure with string keys

Hashmap Library implementing the hash map data structure with open addressing, robin hood hashing more presicely, as a collision resolution strategy.

Data structure manipulation in C

data-structure Data structure manipulation in C This is a set of functions for handling a singly linked list Pros: easy to read and short. the linked

This is a data structure repo written with C++

Data structures In CPP This repo contains many algorithms and data structures in C++. There will be an explanation for each algorithm/data structure.

A simple repo with different data structure programs made in C.
A simple repo with different data structure programs made in C.

Hacktoberfest 2021 - Expert This is an intermediate-level project to help you get started with your [hacktoberfest] (https://hacktoberfest.digitalocea

The Synthesis ToolKit in C++ (STK) is a set of open source audio signal processing and algorithmic synthesis classes written in the C++ programming language.

The Synthesis ToolKit in C++ (STK) By Perry R. Cook and Gary P. Scavone, 1995--2021. This distribution of the Synthesis ToolKit in C++ (STK) contains

Display array is a board that sets 6 ST7735 display with a resolution of 80x160px in a linear array sharing the clock, data, rs, backlight pins together
Display array is a board that sets 6 ST7735 display with a resolution of 80x160px in a linear array sharing the clock, data, rs, backlight pins together

The display array is a board that sets 6 ST7735 display with a resolution of 80x160px in a linear array sharing the clock, data, rs, backlight pins together, and leaving individual access to the cs lines of each display, This board allows you to display images with a resolution of 480x160px.

Data Structure Studying Group: array, linked list, stack, queue, deque, tree, graph. Summary of these concepts are descripted in the markdown files.
Data Structure Studying Group: array, linked list, stack, queue, deque, tree, graph. Summary of these concepts are descripted in the markdown files.

DATA_STRUCTURE STUDY 🏁 CURRICULUM ✔️ Day1 array linked list ✔️ Day2 circular linked list double linked list polynomial addtion reverse linked list ✔️

Easy and efficient audio synthesis in C++

Tonic Fast and easy audio synthesis in C++. Prefer coding to patching? Love clean syntax? Care about performance? That's how we feel too, and why we m

TensorVox is an application designed to enable user-friendly and lightweight neural speech synthesis in the desktop
TensorVox is an application designed to enable user-friendly and lightweight neural speech synthesis in the desktop

TensorVox is an application designed to enable user-friendly and lightweight neural speech synthesis in the desktop, aimed at increasing accessibility to such technology.

A synthesis flow for hybrid processing-in-RRAM modes

reram-synthesis A synthesis flow for hybrid processing-in-ReRAM modes This project contains three parts: digital-synthesis: a synthesis flow for the d

Model synthesis is a technique for generating 2D and 3D shapes from examples.
Model synthesis is a technique for generating 2D and 3D shapes from examples.

Model Synthesis Model synthesis is a technique for generating 2D and 3D shapes from examples. It is inspired by texture synthesis. Model synthesis was

Direct Digital Synthesis DDS with microcontroller
Direct Digital Synthesis DDS with microcontroller

Direct Digital Synthesis DDS with microcontroller DDS is a cool thing. To understand how it works is even cooler. So I wrote a little tutorial about D

ManipNet: Neural Manipulation Synthesis with a Hand-Object Spatial Representation - SIGGRAPH 2021
ManipNet: Neural Manipulation Synthesis with a Hand-Object Spatial Representation - SIGGRAPH 2021

ManipNet: Neural Manipulation Synthesis with a Hand-Object Spatial Representation - SIGGRAPH 2021 Dataset Code Demos Authors: He Zhang, Yuting Ye, Tak

A minimal header-only audio synthesis and processing library

Aurora A minimal header-only C++ audio synthesis and processing toolkit. Getting Started Aurora is a collection of header files which can be included

C++ library for audio and music analysis, description and synthesis, including Python bindings

Essentia Essentia is an open-source C++ library for audio analysis and audio-based music information retrieval released under the Affero GPL license.

Owner
celtera
celtera
Random access array of tightly packed unsigned integers

PackedArray: random access array of tightly packed unsigned integers TLDR PackedArray comes to the rescue when you're in a desperate need for an uint9

Gregory Pakosz 140 Dec 8, 2022
libsais is a library for linear time suffix array and burrows wheeler transform construction based on induced sorting algorithm.

libsais libsais is a library for fast (see Benchmarks below) linear time suffix array and Burrows-Wheeler transform construction based on induced sort

Ilya Grebnov 112 Dec 22, 2022
A collection of array rotation algorithms.

The most commonly used rotation algorithms (aka block swaps) were documented around 1981 and haven't notably changed since. Below I'll describe severa

null 117 Dec 26, 2022
This algorithm is amazing and take a high performance to search something under array.

Sequential Binary Algorithm O(n) Algoritmo Este é um algoritmo de complexidade O(log n), que possui uma alta performance em percorrer um vetor de inte

Guilherme Serafim Kollet 1 Oct 26, 2021
180+ Algorithm & Data Structure Problems using C++

180+ Algorithm & Data Structure Problems using C++

Ravi Mandliya 5.2k Jan 8, 2023
Is a linear data structure with O(log n) searches and O(cbrt n) insertions and index lookups.

A binary cube is a linear data structure that contains a sorted two dimensional dynamic array of nodes which each point to a sorted array

null 22 Jul 13, 2022
Data Structure and Algorithms problems across various platforms.

Covering various practice problems of Arrays, Stacks, queue, tree, graph and different Algorithms. A collection of solutions for Data Structure and Algorithms problems across various platforms in different languages.

Nivedita Singh 42 Oct 29, 2022
Teaching materials for Algorithm Bootcamp: Data Structure.

Data Structure Materials Materials Topics Code Introduction to Data Structures Struct Pointer Dynamic Memory Allocation 00_intro_to_ds.cpp Linked List

pakgembus 50 Jan 7, 2023
The ultimate guide for data structure and algorithms

Quick Notes: For Arrays: (methods that can be applied) sorting and then doing something, hashtable, two pointers in a loop are some of the operations

Intervue 44 Nov 25, 2022
This project Orchid-Fst implements a fast text string dictionary search data structure: Finite state transducer (short for FST) in c++ language.This FST C++ open source project has much significant advantages.

Orchid-Fst 1. Project Overview This project Orchid-Fst implements a fast text string dictionary search data structure: Finite state transducer , which

Bin Ding 10 Oct 18, 2022