Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/X-ARTEMIS/ASTD/llms.txt

Use this file to discover all available pages before exploring further.

ASTD is an open source project licensed under the MIT License, and contributions of all shapes are welcome — whether you are fixing a bug in an existing function, adding a handy new helper to the math module, or proposing an entirely new module. Because ASTD is a header-only library with no build system, the barrier to entry is low: everything lives in .hpp files that you can edit directly with any text editor or IDE.

Repository Structure

Before making changes it helps to understand how the repository is laid out:
ASTD/
├── astd/
│   ├── astd.hpp          ← convenience include (includes all modules)
│   ├── math/
│   │   ├── math.hpp      ← math module convenience header
│   │   ├── cppmath.hpp   ← power(), square(), getNumType()
│   │   └── fraction.hpp  ← fraction<T, U> template class
│   └── time/
│       └── time.hpp      ← astd::getSystemTime(), astd::getSystemTrimmedTime()
└── tests/
    └── math.cpp          ← tests for the math module
The top-level astd/astd.hpp is a convenience header that includes every module:
#pragma once

#include "math/math.hpp"
#include "time/time.hpp"

// Convenience header
Any new module you add must also be included here so that users can reach it with a single #include "astd/astd.hpp".

Code Style

ASTD is written in C++20 and uses modern C++ idioms throughout. Match the style of the surrounding code when contributing:

Auto Parameters

Free functions use abbreviated function templates (auto parameters) rather than explicit template<typename T> declarations where possible.

Template Classes

Data types like fraction<T, U> use explicit template parameters, keeping the types transparent to the caller.

std::chrono

The time module leans on std::chrono including time zones (std::chrono::current_zone()) available in C++20.

Standard Library

Prefer standard library utilities — std::lcm from <numeric>, std::chrono from <chrono> — over third-party dependencies.
Here is a representative snippet showing the style used in astd/math/cppmath.hpp:
auto power(const auto base, const auto exponent) {
    auto powerResult{ 1 };

    if (exponent <= 0) {
        return 1;
    }

    for (int i{ 0 }; i < exponent; ++i) {
        powerResult *= base;
    }

    return powerResult;
}

Types of Contribution and Their Version Impact

Every change you make maps to exactly one tier of ASTD’s semantic versioning policy. Understanding which tier your change falls into helps reviewers merge it with the correct version bump:
Contribution typeVersion bumpExample
Fix a bug in an existing functionPatchCorrecting an edge case in power()
Add a new function to an existing moduleMinorAdding a clamp() function to astd/math/
Introduce a new module/libraryMajorCreating a new astd/string/ module
You do not need to update version numbers yourself — maintainers handle that when tagging a release. Simply describe in your pull request description what kind of change you are making so the right bump can be applied.

How to Contribute

1

Fork and clone the repository

Fork X-ARTEMIS/ASTD on GitHub, then clone your fork locally:
git clone https://github.com/<your-username>/ASTD
cd ASTD
2

Create a feature branch

Work on a dedicated branch rather than committing directly to main:
git checkout -b feat/my-new-function
3

Make your changes

Edit the appropriate .hpp file or create a new module directory. See the sections below for details on each scenario.
4

Write or update tests

Add assertions to the relevant file in tests/. The existing tests/math.cpp shows the pattern:
int main() {
    assert(power(2, 3) == 8);
    // add your assertions here
}
Compile and run your test to verify correctness before pushing.
5

Open a pull request

Push your branch to your fork and open a pull request against the main branch of X-ARTEMIS/ASTD. Include a brief description of what you changed and which version bump tier it falls into.

Adding a Function to an Existing Module

This is a minor change. Find the appropriate .hpp file and add your function following the existing style. Example — adding to the math module: Open astd/math/cppmath.hpp and add your function alongside the existing ones:
// Existing functions: power(), square(), getNumType()

auto clamp(const auto value, const auto low, const auto high) {
    if (value < low) return low;
    if (value > high) return high;
    return value;
}
Then add a test assertion to tests/math.cpp:
int main() {
    assert(power(2, 3) == 8);
    assert(clamp(15, 0, 10) == 10); // your new test
}
The astd/math/math.hpp file is a convenience header that includes cppmath.hpp and fraction.hpp. You do not need to touch it unless you are adding a brand-new .hpp file to the math directory.

Adding a New Module

This is a major change. Creating a wholly new module expands ASTD’s scope and requires updates in two places: 1. Create the module directory and header:
astd/
└── yourmodule/
    └── yourmodule.hpp   ← your implementation goes here
Follow the namespace astd { ... } convention used in astd/time/time.hpp to keep your symbols scoped:
#pragma once

namespace astd {
    // your functions here
}
2. Register the module in the convenience header: Open astd/astd.hpp and add an include for your new module:
#pragma once

#include "math/math.hpp"
#include "time/time.hpp"
#include "yourmodule/yourmodule.hpp"  // ← add this line

// Convenience header
3. Add a test file: Create tests/yourmodule.cpp mirroring the structure of tests/math.cpp:
#include "../astd/astd.hpp"
#include <cassert>

int main() {
    // assert your module's behaviour here
}
New modules are major version bumps per ASTD’s versioning policy. Make sure your pull request description clearly states that a new module is being introduced so maintainers can tag the release appropriately.

Frequently Asked Questions

No. ASTD has no build system. Compile your test file directly with a C++20-capable compiler. For example, with g++:
g++ -std=c++20 tests/math.cpp -o test_math && ./test_math
Replace math with your module name as appropriate.
C++20. The existing codebase uses C++20 features including abbreviated function templates (auto parameters), std::chrono time zones, and std::lcm. Your contributions should compile cleanly under -std=c++20.
Yes, whenever possible. Add an assertion in the relevant tests/ file that reproduces the bug (and passes after your fix). This prevents regressions in future patches.
The fraction<T, U> template class lives in astd/math/fraction.hpp. New methods go inside the class body; new free-function operators go after the class definition, following the existing operator+, operator-, operator*, and operator<< patterns already in the file.

Build docs developers (and LLMs) love