Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constexpr additions #485

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

JustCallMeRay
Copy link
Contributor

I have added constexpr specifiers to Node and Edge classes. These allow for the specified functions and objects to be ran at compile time instead of runtime, resulting in a speed increase.

A possible use case that might result in a speed up:

// load a pylogenic tree from 3 databases
// Base nodes can be constructed at compile time
Node<Enum, Organism> bacteriaBase {  Enum.BacteriaBase, Organism{} };
Node<Enum, Organism> bacteriaBase {  Enum.Archea, Organism{} };
Node<Enum, Organism> bacteriaBase {  Enum.Eukaryota, Organism{} };
// Edges can also be constructed at compile time
Edge ...
// Code cannot be run at compile time so everything after this line cannot be sped up
std::vector<Node<Enum, Organism>> nodes = LoadFromDatabase();

I have changed the UserId to be able to take anything as a template specialisation which may have a possible pain point with const char* being picked over strings and therefor doing a shallow copy over a deep string copy, so I have a static assert to make sure that never happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants