Skip to main content

qtty-cpp

Active

Header-only C++17 library for unit-safe physical quantities, backed by the Rust qtty conversion engine via C FFI.

0 stars
0 forks
C++
AGPL-3.0
Updated today

Why it exists

qtty-cpp provides strongly typed physical quantities (Meter, Second, Kilometer, Radian, …) with user-defined literals and compile-time unit safety for C++ projects. It wraps the Rust qtty-ffi conversion engine so C++ code benefits from the same validated unit conversions.

Key Features

  • Strong types per unit to prevent dimension mixing
  • Unit conversion via Quantity::to<T>()
  • User-defined literals (10.0_km, 5.0_s)
  • Generated headers from qtty-ffi definitions
  • CMake target for easy integration

Getting Started

// CMakeLists.txt
add_subdirectory(path/to/qtty-cpp)
target_link_libraries(myapp PRIVATE qtty_cpp)

// main.cpp
#include "qtty/qtty.hpp"
using namespace qtty;

auto distance = 100.0_km;
auto time = 2.0_h;
auto speed = distance / time;
Meter m = distance.to<Meter>();

Contributing

We welcome contributions! Here's how you can help:

  • 1 Fork the repository and create your branch from main
  • 2 Make your changes and add tests if applicable
  • 3 Ensure all tests pass with cargo test
  • 4 Submit a pull request with a clear description

License

This project is licensed under the AGPL-3.0 license. See the LICENSE file for details.

Latest Release

v0.1.0 Dec 21, 2025
View release notes

Tags

cpp c++17 units physics bindings