T81 Foundation

T81 C++ Quickstart Guide

This page is the C++ portal: it describes how to bootstrap the deterministic ledger (build, tests, code, docs) so every artifact remains reproducible.


1. Prerequisites


2. Build and Test

The project uses a standard CMake workflow.

# 1. Clone the repository
git clone https://github.com/t81dev/t81-foundation.git
cd t81-foundation

# 2. Configure the build (add -G Ninja if you prefer)
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

# 3. Build libraries, examples, tests, and docs
cmake --build build --parallel

# 4. Run the CTest test suite
ctest --test-dir build --output-on-failure

A successful run will show all unit tests passing.

To validate the temporary compatibility lane explicitly:

cmake -S . -B build-cxx20 -DCMAKE_BUILD_TYPE=Release -DT81_USE_CXX23=OFF
cmake --build build-cxx20 --parallel
ctest --test-dir build-cxx20 --output-on-failure

3. “Hello Ternary” Example

The core of the numeric system is the T81Int class. Here is a minimal example of how to use it.

#include <t81/core/T81Int.hpp>
#include <iostream>

int main() {
    using t81::core::T81Int;

    // Create two 8-trit integers from decimal values
    T81Int<8> a{5};
    T81Int<8> b{-3};

    // Arithmetic works as expected
    auto sum = a + b; // 5 + (-3) = 2

    // Convert back to a standard C++ integer for printing
    std::cout << "Sum (decimal): " << sum.to_binary<int64_t>() << std::endl;

    // Print the native balanced ternary representation
    std::cout << "Sum (ternary): " << sum.str() << std::endl;

    return 0;
}

To compile and run this, you would link against the t81_core library.


4. Where to Go Next


5. Notes & Caveats

For a detailed status of all components, see the System Status Report.