Skip to content

SoA (Struct Of Arrays) library using C++26 reflection. Drop-in replacement for standard containers (such as std::vector).

License

Notifications You must be signed in to change notification settings

katkevich/morfo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

morfo

SoA (Struct Of Arrays) library using C++26 reflection. Drop-in replacement for standard containers (such as std::vector).

Quick example

// mrf::cold here is the default bucket (for "cold" data). Person::age and Person::surname will get here
struct[[= mrf::cold]] Person {
    int age = 0;
    [[= mrf::hot]] std::string_view name; // this member will be put in a different bucket (for "hot" data)
    std::string_view surname;
};

mrf::vector<Person> persons;
persons.push_back(Person{ 27, "Ada", "Lovelance" });

const std::vector<mrf::bucket<Person, mrf::cold>>& cold_bucket = persons.bucket<mrf::cold>();
const std::vector<mrf::bucket<Person, mrf::hot>>& hot_bucket = persons.bucket<mrf::hot>();

If you do not specify a default bucket then each non-annotated member will be put in a separate bucket:

// Note: no default bucket for this struct
struct Person {
    int age = 0;                             // 'age' will be put in a separate named bucket (
    [[= mrf::hot]] std::string_view name;    // `name` and `surname` will be put in "hot" bucket
    [[= mrf::hot]] std::string_view surname;
};

mrf::vector<Person> persons;
persons.push_back(Person{ 27, "Ada", "Lovelance" });

const std::vector<mrf::bucket<Person, ^^Person::age>>& age_bucket = persons.bucket<^^Person::age>(); // separate "named" bucket
const std::vector<mrf::bucket<Person, mrf::hot>>& hot_bucket = persons.bucket<mrf::hot>();           // "hot" bucket

About

SoA (Struct Of Arrays) library using C++26 reflection. Drop-in replacement for standard containers (such as std::vector).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published